PHP Class yii\validators\EachValidator

~~~php class MyModel extends Model { public $arrayAttribute = []; public function rules() { return [ checks if every category ID is an integer ['categoryIDs', 'each', 'rule' => ['integer']], ] } } ~~~ > Note: This validator will not work with inline validation rules.
Since: 2.0.4
Author: Paul Klimov ([email protected])
Inheritance: extends Validator
Datei anzeigen Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$allowMessageFromRule whether to use error message composed by validator declared via [[rule]] if its validation fails. If enabled, error message specified for this validator itself will appear only if attribute value is not an array. If disabled, own error message value will be used always.
$rule definition of the validation rule, which should be used on array values. It should be specified in the same format as at [[\yii\base\Model::rules()]], except it should not contain attribute list as the first element. For example: php ['integer'] ['match', 'pattern' => '/[a-z]/is'] Please refer to [[\yii\base\Model::rules()]] for more details.

Public Methods

Method Description
init ( )
validateAttribute ( $model, $attribute )

Protected Methods

Method Description
validateValue ( $value )

Private Methods

Method Description
createEmbeddedValidator ( Model | null $model ) : Validator Creates validator object based on the validation rule specified in [[rule]].
getValidator ( Model | null $model = null ) : Validator Returns the validator declared in [[rule]].

Method Details

init() public method

public init ( )

validateAttribute() public method

public validateAttribute ( $model, $attribute )

validateValue() protected method

protected validateValue ( $value )

Property Details

$allowMessageFromRule public_oe property

whether to use error message composed by validator declared via [[rule]] if its validation fails. If enabled, error message specified for this validator itself will appear only if attribute value is not an array. If disabled, own error message value will be used always.
public $allowMessageFromRule

$rule public_oe property

definition of the validation rule, which should be used on array values. It should be specified in the same format as at [[\yii\base\Model::rules()]], except it should not contain attribute list as the first element. For example: php ['integer'] ['match', 'pattern' => '/[a-z]/is'] Please refer to [[\yii\base\Model::rules()]] for more details.
public $rule