1 | <?php |
||
19 | class EmailValidator extends Validator |
||
20 | { |
||
21 | /** |
||
22 | * @var string the regular expression used to validate the attribute value. |
||
23 | * @see http://www.regular-expressions.info/email.html |
||
24 | */ |
||
25 | 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])?$/'; |
||
26 | /** |
||
27 | * @var string the regular expression used to validate email addresses with the name part. |
||
28 | * This property is used only when [[allowName]] is true. |
||
29 | * @see allowName |
||
30 | */ |
||
31 | 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])?>$/'; |
||
32 | /** |
||
33 | * @var bool whether to allow name in the email address (e.g. "John Smith <[email protected]>"). Defaults to false. |
||
34 | * @see fullPattern |
||
35 | */ |
||
36 | public $allowName = false; |
||
37 | /** |
||
38 | * @var bool whether to check whether the email's domain exists and has either an A or MX record. |
||
39 | * Be aware that this check can fail due to temporary DNS problems even if the email address is |
||
40 | * valid and an email would be deliverable. Defaults to false. |
||
41 | */ |
||
42 | public $checkDNS = false; |
||
43 | /** |
||
44 | * @var bool whether validation process should take into account IDN (internationalized domain |
||
45 | * names). Defaults to false meaning that validation of emails containing IDN will always fail. |
||
46 | * Note that in order to use IDN validation you have to install and enable `intl` PHP extension, |
||
47 | * otherwise an exception would be thrown. |
||
48 | */ |
||
49 | public $enableIDN = false; |
||
50 | |||
51 | |||
52 | /** |
||
53 | * @inheritdoc |
||
54 | */ |
||
55 | 25 | public function init() |
|
65 | |||
66 | /** |
||
67 | * @inheritdoc |
||
68 | */ |
||
69 | 24 | protected function validateValue($value) |
|
104 | |||
105 | 18 | private function idnToAscii($idn) |
|
114 | } |
||
115 |