1 | <?php |
||
24 | class RegularExpressionValidator extends Validator |
||
25 | { |
||
26 | /** |
||
27 | * @var string the regular expression to be matched with |
||
28 | */ |
||
29 | public $pattern; |
||
30 | /** |
||
31 | * @var bool whether to invert the validation logic. Defaults to false. If set to true, |
||
32 | * the regular expression defined via [[pattern]] should NOT match the attribute value. |
||
33 | */ |
||
34 | public $not = false; |
||
35 | |||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | 4 | public function init() |
|
41 | { |
||
42 | 4 | parent::init(); |
|
43 | 4 | if ($this->pattern === null) { |
|
44 | 1 | throw new InvalidConfigException('The "pattern" property must be set.'); |
|
45 | } |
||
46 | 3 | if ($this->message === null) { |
|
47 | 3 | $this->message = Yii::t('yii', '{attribute} is invalid.'); |
|
48 | } |
||
49 | 3 | } |
|
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | */ |
||
54 | 2 | protected function validateValue($value) |
|
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | */ |
||
66 | public function clientValidateAttribute($model, $attribute, $view) |
||
73 | |||
74 | /** |
||
75 | * @inheritdoc |
||
76 | */ |
||
77 | public function getClientOptions($model, $attribute) |
||
94 | } |
||
95 |