PHP Class yii\validators\FilterValidator
FilterValidator is actually not a validator but a data processor.
It invokes the specified filter callback to process the attribute value
and save the processed value back to the attribute. The filter must be
a valid PHP callback with the following signature:
php
function foo($value) {
compute $newValue here
return $newValue;
}
Many PHP functions qualify this signature (e.g.
trim()).
To specify the filter, set [[filter]] property to be the callback.
Show file
Open project: yiisoft/yii2
Class Usage Examples
Public Properties
Property |
Type |
Description |
|
$filter |
|
the filter. This can be a global function name, anonymous function, etc.
The function signature must be as follows,
php
function foo($value) {
compute $newValue here
return $newValue;
}
|
|
$skipOnArray |
|
whether the filter should be skipped if an array input is given.
If true and an array input is given, the filter will not be applied. |
|
$skipOnEmpty |
|
this property is overwritten to be false so that this validator will
be applied when the value being validated is empty. |
|
Public Methods
Method Details
clientValidateAttribute()
public method
validateAttribute()
public method
Property Details
the filter. This can be a global function name, anonymous function, etc.
The function signature must be as follows,
php
function foo($value) {
compute $newValue here
return $newValue;
}
$skipOnArray public property
whether the filter should be skipped if an array input is given.
If true and an array input is given, the filter will not be applied.
$skipOnEmpty public property
this property is overwritten to be false so that this validator will
be applied when the value being validated is empty.