UserFrosting API

RequestSchemaInterface

Represents a schema for an HTTP request, compliant with the WDVSS standard (https://github.com/alexweissman/wdvss).

Tags
author

Alexander Weissman (https://alexanderweissman.com)

Table of Contents

all() Get all items in the schema. array
mergeItems() Recursively merge values (scalar or array) into this repository. mixed
setDefault() Set the default value for a specified field. RequestSchemaInterface
addValidator() Adds a new validator for a specified field. RequestSchemaInterface
removeValidator() Remove a validator for a specified field. RequestSchemaInterface
setTransformations() Set a sequence of transformations for a specified field. RequestSchemaInterface

Methods

mergeItems()

Recursively merge values (scalar or array) into this repository.

public mergeItems( $key : string|null , $items : mixed ) : mixed

If no key is specified, the items will be merged in starting from the top level of the array. If a key IS specified, items will be merged into that key. Nested keys may be specified using dot syntax.

Parameters
$key : string|null
$items : mixed
Return values
mixed

setDefault()

Set the default value for a specified field.

public setDefault( $field : string , $value : string ) : RequestSchemaInterface

If the specified field does not exist in the schema, add it. If a default already exists for this field, replace it with the value specified here.

Parameters
$field : string

The name of the field (e.g., "user_name")

$value : string

The new default value for this field.

Return values
RequestSchemaInterface

This schema object.

addValidator()

Adds a new validator for a specified field.

public addValidator( $field : string , $validatorName : string [, $parameters : array = [] ] ) : RequestSchemaInterface

If the specified field does not exist in the schema, add it. If a validator with the specified name already exists for the field, replace it with the parameters specified here.

Parameters
$field : string

The name of the field for this validator (e.g., "user_name")

$validatorName : string

A validator rule, as specified in https://github.com/alexweissman/wdvss (e.g. "length")

$parameters : array = []

An array of parameters, hashed as parameter_name => parameter value (e.g. [ "min" => 50 ])

Return values
RequestSchemaInterface

This schema object.

setTransformations()

Set a sequence of transformations for a specified field.

public setTransformations( $field : string [, $transformations : string|array = [] ] ) : RequestSchemaInterface

If the specified field does not exist in the schema, add it.

Parameters
$field : string

The name of the field for this transformation (e.g., "user_name")

$transformations : string|array = []

An array of transformations, as specified in https://github.com/alexweissman/wdvss (e.g. "purge")

Return values
RequestSchemaInterface

This schema object.

Search results