Validates an IPv6 address

@param  string $value Value to check against
@return boolean True when $value is a valid ipv6 address
False otherwise
497964
protected function _validateIPv6($value) {
        if (strlen($value) < 3) {
            return $value == '::';
        }

        if (strpos($value, '.')) {
            $lastcolon = strrpos($value, ':');
            if (!($lastcolon && $this->_validateIPv4(substr($value, $lastcolon + 1)))) {
                return false;
            }

            $value = substr($value, 0, $lastcolon) . ':0:0';
        }

        if (strpos($value, '::') === false) {
            return preg_match('/\A(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}\z/i', $value);
        }

        $colonCount = substr_count($value, ':');
        if ($colonCount < 8) {
            return preg_match('/\A(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?\z/i', $value);
        }

        // special case with ending or starting double colon
        if ($colonCount == 8) {
            return preg_match('/\A(?:::)?(?:[a-f0-9]{1,4}:){6}[a-f0-9]{1,4}(?:::)?\z/i', $value);
        }

        return false;
    }
244842
public function validIpv6($ip, $strict = true)
    {
        $flags = FILTER_FLAG_IPV6;
        if ($strict) {
            $flags = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE;
        }

        if (filter_var($ip, FILTER_VALIDATE_IP, array('flags' => $flags)) !== false) {
            return true;
        }

        return false;
    }
785074
public function isValid ($value)
    {
        if (!is_numeric($value)) {
            $this->error(self::INVALID);
            return false;
        }

        if (!preg_match('/^-?[0-9]+([.,][0-9]+)?$/', $value)) {
            $this->error(self::INVALID);
            return false;
        }

        return true;
    }
180476
protected function validateEmailDNS($field, $value)
    {
        if ($this->validateEmail($field, $value)) {
            $domain = \ltrim(\strstr($value, '@'), '@') . '.';
            if (\defined('INTL_IDNA_VARIANT_UTS46') && \function_exists('\idn_to_ascii')) {
                $domain = \idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46);
            }

            return \checkdnsrr($domain, 'ANY');
        }

        return false;
    }
1305880
def _valid_ip6(ip_address):
    '''
    
    '''

    # Validate IPv6 address
    try:
        address = ipaddress.IPv6Address(ip_address)
    except ipaddress.AddressValueError:
        return False

    if address.is_unspecified or \
        address.is_loopback or \
        address.is_link_local or \
        address.is_multicast or \
        address.is_reserved:
        return False

    if address.ipv4_mapped is not None:
        return False

    return True
680750
public function isValid($value)
    {
        if (strlen($value) < 6) {
            $this->error(self::INVALID_TOO_SHORT, "Password too short!");

            return false;
        } elseif (strlen($value) > 20) {
            $this->error(self::INVALID_TOO_LONG, "Password too long!");

            return false;
        } elseif (!preg_match("#[0-9]+#", $value)) {
            $this->error(self::INVALID_ONE_NUMBER, "Password must include at least one number!");

            return false;
        } elseif (!preg_match("#[a-z]+#", $value)) {
            $this->error(self::INVALID_ONE_LETTER, "Password must include at least one letter!");

            return false;
        }

        return true;
    }
346568
public function validateValue($value)
    {
        list($domain, $ip) = explode('/', $value, 2);
        if (($error = (new DomainValidator())->validateValue($domain)) !== null) {
            return $error;
        }
        if ($ip !== null && ($error = (new IpValidator())->validateValue($ip)) !== null) {
            return $error;
        }

        return null;
    }
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;
    }
408918
public function validate($value = "")
    {
        if (is_null($value) && $this->isEmptyAllowed()) {
            return true;
        }

        if ($this->isNullNotAllowed() && is_null($value)) {
            return false;
        }

        return true;
    }
841269
protected function _validate($value)
    {
        $value = trim(str_replace('\\', '/', $value));
        return (is_string($value) && (preg_match(self::PATTERN, $value)) == 1);
    }
840064
public function validate($value) {
        if(!filter_var($value, FILTER_VALIDATE_IP, $this->flags)) {
            return new ValidationResult(false, 'Not a valid ip address');
        }        
        return new ValidationResult(true);
    }
1140085
public function isValid($value)
    {
        if (!$value instanceof ApplicationInterface) {
            $this->error('NO_APPLICATION');

            return false;
        }

        $error = false;

        if ('' == $value->getContact()->getEmail()) {
            $error = true;
            $this->error('NO_EMAIL');
        }

        if (!$value->getAttributes()->getAcceptedPrivacyPolicy()) {
            $error = true;
            $this->error('NO_ACCEPT_PP');
        }

        return !$error;
    }
1319912
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

        if (ip2long($valueString) === false) {
            $this->_error();
            return false;
        }

        return true;
    }
1000801
public function isValueValid($value) {
		return $value instanceof Type\Distance || $value instanceof DataType\NumberType || $value instanceof DataType\TextType;
	}
1319492
protected function isValueValid($value) {
		$this->checkValue($value);
		
		if ($this->validatable === null) {
			return true;
		}
		
		return $this->validatable->testEiFieldValue($this->eiu, $value);
	}
931253
public function isValid($value)
    {
        if (!is_string($value) && !is_int($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        $this->_setValue($value);
        if (!ctype_xdigit((string) $value)) {
            $this->_error(self::NOT_HEX);
            return false;
        }

        return true;
    }
832448
public function isValid($value)
    {
        if (!preg_match('/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/', $value)) {
            return $this->_error(self::INVALID);
        }
        foreach (explode('.', $value) as $num) {
            if ($num > 255 || $num < 0) {
                return false;
            }
        }
        return true;
    }