Validate that a field is an active URL by verifying DNS record

@param  string $field
@param  mixed  $value

@return bool
434165
protected function validateUrlActive($field, $value)
    {
        foreach (static::$validUrlPrefixes as $prefix) {
            if (\strpos($value, $prefix) !== false) {
                $host = \parse_url(\strtolower($value), PHP_URL_HOST);

                return \checkdnsrr($host, 'A') || \checkdnsrr($host, 'AAAA') || \checkdnsrr($host, 'CNAME');
            }
        }

        return false;
    }
71162
public function isValid($value)
    {
        //niepoprawna quera
        if (!($this->getQuery() instanceof \Mmi\Orm\Query)) {
            throw new ValidatorException('No query class supplied.');
        }
        //brak pola
        if (!$this->getField()) {
            throw new ValidatorException('No field name supplied.');
        }
        $q = $this->getQuery();
        /* @var $q \Mmi\Orm\Query */
        $q->where($this->getField())->equals($value);
        if ($this->getId()) {
            $q->andField('id')->notEquals(intval($this->getId()));
        }
        //rekord istnieje
        if ($q->count() > 0) {
            return $this->_error(self::INVALID);
        }
        return true;
    }
1051148
protected function validateRequired($field, $value)
    {
        if (is_null($value)) {
            return false;
        } elseif (is_string($value) && '' === trim($value)) {
            return false;
        }

        return true;
    }
253382
public function run( $field, $value, $message = null ) {
        $this->field   = $field;
        $this->message = $message;

        return filter_var( $value, FILTER_VALIDATE_URL ) !== false;
    }
248300
public function setField($field,$value='') {
        if(is_array($field)) {
            $data           =   $field;
        }else{
            $data[$field]   =   $value;
        }
        return $this->save($data);
    }
722
public function validate($value)
    {
        $result = false;

        if (is_string($value) && strlen($value))
        {
            if ($value[0] == '/' || $value[0] == '\\'
                || (strlen($value) > 3 && ctype_alpha($value[0])
                    && $value[1] == ':'
                    && ($value[2] == '\\' || $value[2] == '/')
                )
                || null !== parse_url($value, PHP_URL_SCHEME)
            ) {
                $result = true;
            }
        }

        return $result;
    }
55694
protected function validateRequired($field, $value, array $params = [], array $fields = [])
    {
        if (isset($params[0]) && (bool) $params[0]) {
            $find = $this->getPart($fields, \explode('.', $field), true);

            return $find[1];
        }

        if (null === $value) {
            return false;
        }

        if (\is_string($value) && \trim($value) === '') {
            return false;
        }

        return true;
    }
551872
protected function validateLengthMax($field, $value, $params)
    {
        $length = $this->stringLength($value);

        return ($length !== false) && $length <= $params[0];
    }
1164615
public function validate($field, $value, $validator) {

		if(empty($value)) return false;
		if(!filter_var($value, FILTER_VALIDATE_URL)) return false;

		$url = parse_url($value);
		if(!in_array($url['scheme'], $this->allowed_protocols)) return false;

		if($this->allowed_domains === null) return true;

		return in_array($url['host'], $this->allowed_domains);

	}
920322
protected function validateDigitsBetween($field, $value, $params)
    {
        $length = strlen((string) $value);

        return !preg_match('/[^0-9]/', $value) && $length >= $params[0] && $length <= $params[1];
    }
1128958
protected function validate_baseurl($value) {
        global $CFG;
        include_once($CFG->dirroot . '/lib/validateurlsyntax.php');
        if (!empty($value) && !validateUrlSyntax($value, 'S+')) {
            return new lang_string('sslonlyaccess', 'error');
        }
        return true;
    }
480526
protected function validate_valid_url($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field])) {
            return;
        }

        if (!filter_var($input[$field], FILTER_VALIDATE_URL)) {
            return array(
                'field' => $field,
                'value' => $input[$field],
                'rule' => __FUNCTION__,
                'param' => $param,
            );
        }
    }
1060299
protected function validateBetween($field, $value, $params)
    {
        if (!\is_numeric($value)) {
            return false;
        }
        if (!isset($params[0]) || !\is_array($params[0]) || \count($params[0]) !== 2) {
            return false;
        }

        list($min, $max) = $params[0];

        return $this->validateMin($field, $value, [$min]) && $this->validateMax($field, $value, [$max]);
    }
1066769
public function validate($field, $value, $validator) {
		if(empty($value)) return true;
		return (bool) preg_match($this->regex, $value);
	}
370668
protected function _validate_url($value)
    {
        if ($value === '') {
            return '';
        }

        if (strpos($value, '://') === false) {
            $value = 'http://' . $value;
        }

        return filter_var($value, FILTER_VALIDATE_URL) !== false ? $value : null;
    }
255184
public static function typeUrl($value, array $params, array $field)
    {
        return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_URL);
    }
568484
final public function setRowFieldValue($field, $value)
    {

        //If value exists;
        if (array_key_exists($field, $this->schema)) {
            $this->schema[$field]->Value = $value;
            return true;
        }
        return false;
    }