Base class for any pclib Validator.
More...
|
| validateRule ($value, $rule, $param=null) |
| Validate $value using $rule. More...
|
|
| service ($service, $default=null) |
| Try acquire $service and load it into property $this->$service. More...
|
|
|
| $rules = array() |
| Array of rule handlers [ruleName: callable, ...].
|
|
| $errors = array() |
| Array of [fieldName: errorMessage, ...].
|
|
| $parser |
| var TplParser
|
|
|
static | defaults () |
| Set or retireve default parameters of the object. More...
|
|
Base class for any pclib Validator.
Features:
◆ hasRule()
Check if validator has handler for rule $rule.
- Parameters
-
◆ setError()
setError |
( |
|
$id, |
|
|
|
$messageId, |
|
|
array |
$args = array() |
|
) |
| |
Set error message for element $id.
Called when validation of element's value failed.
- Parameters
-
string | $id | Element-id |
string | $messageId | Id such as 'email', 'required' or full message text |
◆ setRule()
setRule |
( |
|
$name, |
|
|
|
$function, |
|
|
|
$message |
|
) |
| |
Set or add new rule.
- Parameters
-
string | $name | Rule name |
callable | $function | Rule handler |
string | $message | Rule error message |
◆ validate()
validate |
( |
|
$value, |
|
|
|
$rules |
|
) |
| |
Validate $value against $rules.
Example: validate('1.1.2016', 'date required')
- Parameters
-
- Returns
- bool isValid
◆ validateArray()
validateArray |
( |
array |
$values, |
|
|
array |
$elements |
|
) |
| |
Validate array of values, using validation rules in $elements.
Set $this->errors array.
- Parameters
-
array | $values | [id => value, ...] |
array | $elements | [id => array_of_rules, ...] |
- Returns
- bool isValid
◆ validateElement()
validateElement |
( |
|
$value, |
|
|
array |
$elem |
|
) |
| |
Validate $value against $elem rules.
- Parameters
-
mixed | $value | |
array | $elem | [rule => param, ...] e.g. ['date' => 1, 'required' => 1] |
- Returns
- bool isValid
◆ validateRule()
validateRule |
( |
|
$value, |
|
|
|
$rule, |
|
|
|
$param = null |
|
) |
| |
|
protected |
Validate $value using $rule.
Example: validateRule('1.1.2016', 'date', 'd.m.Y')
- Parameters
-
mixed | $value | |
string | $rule | |
mixed | $param | Rule parameters |
- Returns
- bool isValid
The documentation for this class was generated from the following file: