1 | <?php |
||
38 | class EachValidator extends Validator |
||
39 | { |
||
40 | /** |
||
41 | * @var array|Validator definition of the validation rule, which should be used on array values. |
||
42 | * It should be specified in the same format as at [[yii\base\Model::rules()]], except it should not |
||
43 | * contain attribute list as the first element. |
||
44 | * For example: |
||
45 | * |
||
46 | * ```php |
||
47 | * ['integer'] |
||
48 | * ['match', 'pattern' => '/[a-z]/is'] |
||
49 | * ``` |
||
50 | * |
||
51 | * Please refer to [[yii\base\Model::rules()]] for more details. |
||
52 | */ |
||
53 | public $rule; |
||
54 | /** |
||
55 | * @var boolean whether to use error message composed by validator declared via [[rule]] if its validation fails. |
||
56 | * If enabled, error message specified for this validator itself will appear only if attribute value is not an array. |
||
57 | * If disabled, own error message value will be used always. |
||
58 | */ |
||
59 | public $allowMessageFromRule = true; |
||
60 | |||
61 | /** |
||
62 | * @var Validator validator instance. |
||
63 | */ |
||
64 | private $_validator; |
||
65 | |||
66 | |||
67 | /** |
||
68 | * @inheritdoc |
||
69 | */ |
||
70 | 6 | public function init() |
|
77 | |||
78 | /** |
||
79 | * Returns the validator declared in [[rule]]. |
||
80 | * @param Model|null $model model in which context validator should be created. |
||
81 | * @return Validator the declared validator. |
||
82 | */ |
||
83 | 6 | private function getValidator($model = null) |
|
90 | |||
91 | /** |
||
92 | * Creates validator object based on the validation rule specified in [[rule]]. |
||
93 | * @param Model|null $model model in which context validator should be created. |
||
94 | * @throws \yii\base\InvalidConfigException |
||
95 | * @return Validator validator instance |
||
96 | */ |
||
97 | 6 | private function createEmbeddedValidator($model) |
|
111 | |||
112 | /** |
||
113 | * @inheritdoc |
||
114 | */ |
||
115 | 3 | public function validateAttribute($model, $attribute) |
|
132 | |||
133 | /** |
||
134 | * @inheritdoc |
||
135 | */ |
||
136 | 5 | protected function validateValue($value) |
|
160 | } |
||
161 |