ClientSideValidationAdapter
ClientSideValidationAdapter Class.
Loads validation rules from a schema and generates client-side rules compatible with a particular client-side (usually Javascript) plugin.
Tags
Table of Contents
$schema | RequestSchemaInterface | |
---|---|---|
$translator | Translator | |
__construct() | Create a new client-side validator. | mixed |
setSchema() | Set the schema for this validator. | mixed |
setTranslator() | Set the translator for this validator, as a valid MessageTranslator object. | mixed |
rules() | Generate and return the validation rules for this specific validation adapter. | mixed |
Properties
$schema
protected
RequestSchemaInterface
$schema
$translator
protected
Translator
$translator
Methods
__construct()
Create a new client-side validator.
public
__construct(
$schema :
RequestSchemaInterface
, $translator :
Translator
)
: mixed
Parameters
- $schema : RequestSchemaInterface
A RequestSchema object, containing the validation rules.
- $translator : Translator
A Translator to be used to translate message ids found in the schema.
Return values
mixedsetSchema()
Set the schema for this validator.
public
setSchema(
$schema :
RequestSchemaInterface
)
: mixed
Parameters
- $schema : RequestSchemaInterface
A RequestSchemaInterface object, containing the validation rules.
Return values
mixedsetTranslator()
Set the translator for this validator, as a valid MessageTranslator object.
public
setTranslator(
$translator :
Translator
)
: mixed
Parameters
- $translator : Translator
A Translator to be used to translate message ids found in the schema.
Return values
mixedrules()
Generate and return the validation rules for this specific validation adapter.
public
abstract rules(
[ $format :
string
= 'json' ]
[, $stringEncode :
bool
= true ]
)
: mixed
This method returns a collection of rules, in the format required by the specified plugin.
Parameters
- $format : string = 'json'
The format in which to return the rules. For example, "json" or "html5".
- $stringEncode : bool = true
In the case of JSON rules, specify whether or not to encode the result as a serialized JSON string.
Return values
mixed —The validation rule collection.