yii\validators\UrlValidator::validateValue PHP Method

validateValue() protected method

protected validateValue ( $value )
    protected function validateValue($value)
    {
        // make sure the length is limited to avoid DOS attacks
        if (is_string($value) && strlen($value) < 2000) {
            if ($this->defaultScheme !== null && strpos($value, '://') === false) {
                $value = $this->defaultScheme . '://' . $value;
            }
            if (strpos($this->pattern, '{schemes}') !== false) {
                $pattern = str_replace('{schemes}', '(' . implode('|', $this->validSchemes) . ')', $this->pattern);
            } else {
                $pattern = $this->pattern;
            }
            if ($this->enableIDN) {
                $value = preg_replace_callback('/:\\/\\/([^\\/]+)/', function ($matches) {
                    return '://' . idn_to_ascii($matches[1]);
                }, $value);
            }
            if (preg_match($pattern, $value)) {
                return null;
            }
        }
        return [$this->message, []];
    }