Public Member Functions | |
__construct (array $rules) | |
get ($property, $context=null) | |
rules () | |
addRules (array $rules) | |
A wrapper around a set oaf validation rules which can be used to select the appropriate validator in a given context.
The validation rules are structured as follows:
Here the <property>
key is the name of the property being validated, which may be a string (the property name) or a tuple
of strings (the property name and the namespace for the property name).
If a context
is provided, then if the top level property is being validated, and it appears inside a field present in the context
then the default
validator at the top level is overridden by the default
validator in the context
.
For example, consider the following rules:
This tells us that the TYPE
property should be validated with typeChecker
by default. But if we are looking at that TYPE
property inside an ACTOR
object, then instead we should use validate.one_of
.
When the get
method is called, the context
parameter can be used to specify the context in which the property is being validated.
coarnotify\validate\Validator::__construct | ( | array | $rules | ) |
Create a new validator with the given rules
array | $rules | The rules to use for validation |
coarnotify\validate\Validator::addRules | ( | array | $rules | ) |
Add new rules to the existing ruleset
array | $rules |
coarnotify\validate\Validator::get | ( | $property, | |
$context = null ) |
Get the validation function for the given property in the given context
string | array | $property | The property to get the validation function for |
string | array | null | $context | The context in which the property is being validated |
coarnotify\validate\Validator::rules | ( | ) |
The ruleset for this validator