1 | <?php |
||
21 | class EmailValidator extends Validator |
||
22 | { |
||
23 | /** |
||
24 | * @var string the regular expression used to validate the attribute value. |
||
25 | * @see http://www.regular-expressions.info/email.html |
||
26 | */ |
||
27 | public $pattern = '/^[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/'; |
||
28 | /** |
||
29 | * @var string the regular expression used to validate email addresses with the name part. |
||
30 | * This property is used only when [[allowName]] is true. |
||
31 | * @see allowName |
||
32 | */ |
||
33 | public $fullPattern = '/^[^@]*<[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?>$/'; |
||
34 | /** |
||
35 | * @var bool whether to allow name in the email address (e.g. "John Smith <[email protected]>"). Defaults to false. |
||
36 | * @see fullPattern |
||
37 | */ |
||
38 | public $allowName = false; |
||
39 | /** |
||
40 | * @var bool whether to check whether the email's domain exists and has either an A or MX record. |
||
41 | * Be aware that this check can fail due to temporary DNS problems even if the email address is |
||
42 | * valid and an email would be deliverable. Defaults to false. |
||
43 | */ |
||
44 | public $checkDNS = false; |
||
45 | /** |
||
46 | * @var bool whether validation process should take into account IDN (internationalized domain |
||
47 | * names). Defaults to false meaning that validation of emails containing IDN will always fail. |
||
48 | * Note that in order to use IDN validation you have to install and enable `intl` PHP extension, |
||
49 | * otherwise an exception would be thrown. |
||
50 | */ |
||
51 | public $enableIDN = false; |
||
52 | |||
53 | |||
54 | /** |
||
55 | * @inheritdoc |
||
56 | */ |
||
57 | 8 | public function init() |
|
67 | |||
68 | /** |
||
69 | * @inheritdoc |
||
70 | */ |
||
71 | 7 | protected function validateValue($value) |
|
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function clientValidateAttribute($model, $attribute, $view) |
||
120 | |||
121 | /** |
||
122 | * @inheritdoc |
||
123 | */ |
||
124 | public function getClientOptions($model, $attribute) |
||
141 | } |
||
142 |