1 | <?php |
||
22 | class UrlValidator extends Validator |
||
23 | { |
||
24 | /** |
||
25 | * @var string the regular expression used to validate the attribute value. |
||
26 | * The pattern may contain a `{schemes}` token that will be replaced |
||
27 | * by a regular expression which represents the [[validSchemes]]. |
||
28 | */ |
||
29 | public $pattern = '/^{schemes}:\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(?::\d{1,5})?(?:$|[?\/#])/i'; |
||
30 | /** |
||
31 | * @var array list of URI schemes which should be considered valid. By default, http and https |
||
32 | * are considered to be valid schemes. |
||
33 | */ |
||
34 | public $validSchemes = ['http', 'https']; |
||
35 | /** |
||
36 | * @var string the default URI scheme. If the input doesn't contain the scheme part, the default |
||
37 | * scheme will be prepended to it (thus changing the input). Defaults to null, meaning a URL must |
||
38 | * contain the scheme part. |
||
39 | */ |
||
40 | public $defaultScheme; |
||
41 | /** |
||
42 | * @var bool whether validation process should take into account IDN (internationalized |
||
43 | * domain names). Defaults to false meaning that validation of URLs containing IDN will always |
||
44 | * fail. Note that in order to use IDN validation you have to install and enable `intl` PHP |
||
45 | * extension, otherwise an exception would be thrown. |
||
46 | */ |
||
47 | public $enableIDN = false; |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | 7 | public function init() |
|
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | 1 | public function validateAttribute($model, $attribute) |
|
77 | |||
78 | /** |
||
79 | * @inheritdoc |
||
80 | */ |
||
81 | 7 | protected function validateValue($value) |
|
108 | |||
109 | 1 | private function idnToAscii($idn) |
|
118 | } |
||
119 |