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