UserFrosting API

RequestSchema extends RequestSchemaRepository

RequestSchema Class.

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

$loader FileRepositoryLoader
__construct() Loads the request schema from a file. mixed
getSchema() array
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
mergeItems() Recursively merge values (scalar or array) into this repository. self
getDefined() Get the specified configuration value, recursively removing all null values. mixed

Properties

Methods

__construct()

Loads the request schema from a file.

public __construct( [ $path : string = null ] ) : mixed
Parameters
$path : string = null

The full path to the file containing the WDVSS schema.

Return values
mixed

getSchema()

public getSchema( ) : array
Tags
deprecated

since 4.1. Use all() instead

Return values
array

The schema data.

setDefault()

Set the default value for a specified field.

public setDefault( $field : mixed , $value : mixed ) : 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 : mixed

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

$value : mixed

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 : mixed , $validatorName : mixed [, $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 : mixed

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

$validatorName : mixed

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 : mixed [, $transformations : mixed = [] ] ) : RequestSchemaInterface

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

Parameters
$field : mixed

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

$transformations : mixed = []

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

Return values
RequestSchemaInterface

This schema object.

mergeItems()

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

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

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
self

getDefined()

Get the specified configuration value, recursively removing all null values.

public getDefined( [ $key : string|array|null = null ] ) : mixed
Parameters
$key : string|array|null = null
Return values
mixed

Search results