PHP Класс 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.
С версии: 2.0.4
Автор: Paul Klimov ([email protected])
Наследование: extends Validator
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
init ( )
validateAttribute ( $model, $attribute )

Защищенные методы

Метод Описание
validateValue ( $value )

Приватные методы

Метод Описание
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]].

Описание методов

init() публичный Метод

public init ( )

validateAttribute() публичный Метод

public validateAttribute ( $model, $attribute )

validateValue() защищенный Метод

protected validateValue ( $value )

Описание свойств

$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.
public $allowMessageFromRule

$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 $rule