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
Afficher le fichier Open project: yiisoft/yii2 Class Usage Examples

Méthodes publiques

Свойство 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.

Méthodes publiques

Méthode Description
init ( )
validateAttribute ( $model, $attribute )

Méthodes protégées

Méthode Description
validateValue ( $value )

Private Methods

Méthode 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 méthode

public init ( )

validateAttribute() public méthode

public validateAttribute ( $model, $attribute )

validateValue() protected méthode

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