Provided to each validation method to provide useful methods and validation context information.
__construct(\Pajama\Validator $validator)
\Pajama\Validator
getValidator() : \Pajama\Validator
optional(string $value) : bool
Example:
Validator::addMethod('example', function($context, $value) {
return $context->optional($value) || ...;
}
string
The value to test.
bool
True if the value is null or an empty string, false otherwise.parseSelector(string $selector) : array | null
A Pajama-compatible selector has the format:
The two parts are:
Example:
$context = ...;
$parts = $context->parseSelector('[name=foo]:checked]');
// $parts['name'] === 'foo'
// $parts['pseudo-class'] === 'checked'
string
A Pajama-compatible selector.
array
null
An array containing the two parts of the selector or null if the selector could not be parsed.resolve(string $value, bool | string | callable $param) : bool
string
The value to be passed to the param if it is a callable.
bool
string
callable
The parameter to resolve.
bool
resolveExpression(string $expression) : bool
string
bool