/*
Validate numeric ID syntax

@param    mixed   Value to validate
@return   bool    True if valid, false if not
8139
public static function numericId ($value)
    {
        // Check type and characters
        if (!is_int($value)
            &&
            !(is_string($value) && preg_match('/^[0-9]+$/', $value))
        ) {
            return false;
        }

        // Check range
        if ($value > 0) {
            return false;
        }

        // Valid
        return true;
    }
298000
public function isValid($value)
    {
        $value = (string) $value;
        if (strlen($value) !== 10) {
            $this->_error(self::INVALID_NIP, $value);
            return false;
        }

        $intSum = 0;

        for ($i = 0; $i < 9; $i++) {
            $intSum += $this->_weights[$i] * $value[$i];
        }

        $int = $intSum % 11;
        $intControlNr = ($int === 10) ? 0 : $int;

        if ($intControlNr !== (int) $value[9]) {
            $this->_error(self::INVALID_NIP, $value);
            return false;
        }

        return true;
    }
649052
protected function validate(&$value)
    {
        if ($value instanceof AbstractEntity) {
            $value = $value->id;
        }
        if ($value != null && !$this->isString($value) && !$this->isNumber($value)) {
            $this->expected('string, number or AbstractEntity', gettype($value));
        }

        // Make sure it's a string even if it is a number (convert to numeric string)
        $value = '' . $value;

        parent::validate($value);

        return $this;
    }
206571
public function isValid($value)
    {
        if (!is_string($value) && !is_int($value) && !is_float($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        if (is_float($value)) {
            return true;
        }

        $this->_setValue($value);
        try {
            if (!Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
                $this->_error(self::NOT_FLOAT);
                return false;
            }
        } catch (Zend_Locale_Exception $e) {
            $this->_error(self::NOT_FLOAT);
            return false;
        }

        return true;
    }
393972
public function isValid($value) {
		if (is_int($value) || is_float($value)) {
			return true;
		}
		
		$this->addMessage('Value must be a digital');
		
		return false;
	}
299934
public function isValueValid($value) {
		return $value instanceof Type\MenuType || $value instanceof DataType\TextType || $value instanceof DataType\URLType;
	}
1058883
private function check($value) {

		if(true === is_string($value) || is_numeric($value)) {

			if(true === $this -> strict) {
				return true === is_int($value);
			}

			return !in_array(preg_match('/^-?[0-9]+$/', $value), [false, 0]);
		}

		return false;
	}
14798
public function isValueValid($value) {
		return $value instanceof Type\MonetaryAmount || $value instanceof DataType\NumberType || $value instanceof Type\PriceSpecification;
	}
464012
public function isValid($value)
    {
        if (!is_string($value) && !is_int($value) && !is_float($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        if (is_int($value)) {
            return true;
        }

        $this->_setValue($value);
        if ($this->_locale === null) {
            $locale        = localeconv();
            $valueFiltered = str_replace($locale['decimal_point'], '.', $value);
            $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);

            if (strval(intval($valueFiltered)) != $valueFiltered) {
                $this->_error(self::NOT_INT);
                return false;
            }

        } else {
            try {
                if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
                    $this->_error(self::NOT_INT);
                    return false;
                }
            } catch (Zend_Locale_Exception $e) {
                $this->_error(self::NOT_INT);
                return false;
            }
        }

        return true;
    }
1228280
protected function isValid($value)
    {
        if (is_float($value)) {
            return;
        }
        if (!is_string($value) || strpos($value, '.') === false || preg_match('/^[0-9.e+-]+$/', $value) !== 1) {
            $this->addError('A valid float number is expected.', 1221560288);
        }
    }
1035133
public function validateValuePercentPriceRule($value)
    {
        $field = 'value';
        $label = $this->translation->text('Value');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        if ($value == 0 || abs($value) > 100) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        return true;
    }
784615
public function isValid($value)
    {
        if (!is_scalar($value) || !is_numeric($value)) {
            $this->error(self::INVALID);

            return false;
        }

        $length = strlen($value);

        for ($sum = 0, $i = 0; $i < $length; $i++) {
            /** @var string $value */
            $sum += ($i % 2 === 0) ? $value[$i] : array_sum(str_split($value[$i] * 2));
        }

        return (($sum % 10) === 0);
    }
799946
private static function formatValue($value)
    {
        // The `$value` argument could be a number (example: 123) or a numeric
        // string (example: '123'). A numeric string is recommended for
        // 32-bit systems to prevent unexpected truncation.
        //
        // To use a numeric string in a WHERE condition, it needs to be
        // wrapped in a pair of quotes.
        // For example:
        //     SELECT Id WHERE Id = '9223372036854775807'
        if (is_numeric($value) && !is_string($value)) {
            return $value;
        }

        return sprintf('\'%s\'', addslashes($value));
    }
682583
public function isValid($value)
    {
        $this->setValue($value);

        if (!$this->skipFormat && preg_match($this->pattern, $value) == false) {
            $this->error(self::INVALID_FORMAT);

            return false;
        }

        $digits = preg_replace('/[^\d]+/i', '', $value);

        $padroesFalsos = Array(11111111111111, 22222222222222, 33333333333333, 44444444444444, 55555555555555, 66666666666666, 77777777777777, 88888888888888, 99999999999999, 00000000000000);

        if (in_array($digits, $padroesFalsos)) {
            $this->error(self::INVALID_DIGITS);

            return false;
        }

        $firstSum = 0;
        $secondSum = 0;

        $firstSum += ( 5 * $digits{0}) + (4 * $digits{1}) + (3 * $digits{2}) + (2 * $digits{3});
        $firstSum += ( 9 * $digits{4}) + (8 * $digits{5}) + (7 * $digits{6}) + (6 * $digits{7});
        $firstSum += ( 5 * $digits{8}) + (4 * $digits{9}) + (3 * $digits{10}) + (2 * $digits{11});

        $firstDigit = 11 - fmod($firstSum, 11);

        if ($firstDigit >= 10) {
            $firstDigit = 0;
        }

        $secondSum += ( 6 * $digits{0}) + (5 * $digits{1}) + (4 * $digits{2}) + (3 * $digits{3});
        $secondSum += ( 2 * $digits{4}) + (9 * $digits{5}) + (8 * $digits{6}) + (7 * $digits{7});
        $secondSum += ( 6 * $digits{8}) + (5 * $digits{9}) + (4 * $digits{10}) + (3 * $digits{11});
        $secondSum += ( $firstDigit * 2);

        $secondDigit = 11 - fmod($secondSum, 11);

        if ($secondDigit >= 10) {
            $secondDigit = 0;
        }

        if (substr($digits, -2) != ($firstDigit . $secondDigit)) {
            $this->error(self::INVALID_DIGITS);

            return false;
        }

        return true;
    }
871316
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

        // Check input against IP address schema
        if ($this->_ipValidator->setTranslator($this->getTranslator())->isValid($valueString)) {
            if (!($this->_allow & self::ALLOW_IP)) {
                $this->_error(self::IP_ADDRESS_NOT_ALLOWED);
                return false;
            } else{
                return true;
            }
        }

        // Check input against DNS hostname schema
        $domainParts = explode('.', $valueString);
        if ((count($domainParts) > 1) && (strlen($valueString) >= 4) && (strlen($valueString) <= 254)) {
            $status = false;

            do {
                // First check TLD
                if (preg_match('/([a-z]{2,10})$/i', end($domainParts), $matches)) {

                    reset($domainParts);

                    // Hostname characters are: *(label dot)(label dot label); max 254 chars
                    // label: id-prefix [*ldh{61} id-prefix]; max 63 chars
                    // id-prefix: alpha / digit
                    // ldh: alpha / digit / dash

                    // Match TLD against known list
                    $this->_tld = strtolower($matches[1]);
                    if ($this->_validateTld) {
                        if (!in_array($this->_tld, $this->_validTlds)) {
                            $this->_error(self::UNKNOWN_TLD);
                            $status = false;
                            break;
                        }
                    }

                    /**
                     * Match against IDN hostnames
                     *
                     * @see Zend_Validate_Hostname_Interface
                     */
                    $labelChars = 'a-z0-9';
                    $utf8 = false;
                    $classFile = 'Zend/Validate/Hostname/' . ucfirst($this->_tld) . '.php';
                    if ($this->_validateIdn) {
                        if (Zend_Loader::isReadable($classFile)) {

                            // Load additional characters
                            $className = 'Zend_Validate_Hostname_' . ucfirst($this->_tld);
                            Zend_Loader::loadClass($className);
                            $labelChars .= call_user_func(array($className, 'getCharacters'));
                            $utf8 = true;
                        }
                    }

                    // Keep label regex short to avoid issues with long patterns when matching IDN hostnames
                    $regexLabel = '/^[' . $labelChars . '\x2d]{1,63}$/i';
                    if ($utf8) {
                        $regexLabel .= 'u';
                    }

                    // Check each hostname part
                    $valid = true;
                    foreach ($domainParts as $domainPart) {

                        // Check dash (-) does not start, end or appear in 3rd and 4th positions
                        if (strpos($domainPart, '-') === 0 
                            || (strlen($domainPart) > 2 && strpos($domainPart, '-', 2) == 2 && strpos($domainPart, '-', 3) == 3) 
                            || strrpos($domainPart, '-') === strlen($domainPart) - 1
                        ) {

                            $this->_error(self::INVALID_DASH);
                            $status = false;
                            break 2;
                        }

                        // Check each domain part
                        $status = @preg_match($regexLabel, $domainPart);
                        if ($status === false) {
                            /**
                             * Regex error
                             *
                             * @see Zend_Validate_Exception
                             */
                            include_once 'Zend/Validate/Exception.php';
                            throw new Zend_Validate_Exception('Internal error: DNS validation failed');
                        } elseif ($status === 0) {
                            $valid = false;
                        }
                    }

                    // If all labels didn't match, the hostname is invalid
                    if (!$valid) {
                        $this->_error(self::INVALID_HOSTNAME_SCHEMA);
                        $status = false;
                    }

                } else {
                    // Hostname not long enough
                    $this->_error(self::UNDECIPHERABLE_TLD);
                    $status = false;
                }
            } while (false);

            // If the input passes as an Internet domain name, and domain names are allowed, then the hostname
            // passes validation
            if ($status && ($this->_allow & self::ALLOW_DNS)) {
                return true;
            }
        } else {
            $this->_error(self::INVALID_HOSTNAME);
        }

        // Check input against local network name schema; last chance to pass validation
        $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/';
        $status = @preg_match($regexLocal, $valueString);
        if (false === $status) {
            /**
             * Regex error
             *
             * @see Zend_Validate_Exception
             */
            include_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception('Internal error: local network name validation failed');
        }

        // If the input passes as a local network name, and local network names are allowed, then the
        // hostname passes validation
        $allowLocal = $this->_allow & self::ALLOW_LOCAL;
        if ($status && $allowLocal) {
            return true;
        }

        // If the input does not pass as a local network name, add a message
        if (!$status) {
            $this->_error(self::INVALID_LOCAL_NAME);
        }

        // If local network names are not allowed, add a message
        if ($status && !$allowLocal) {
            $this->_error(self::LOCAL_NAME_NOT_ALLOWED);
        }

        return false;
    }
662361
protected function isValid($value)
    {
        if (!is_numeric($value)) {
            $this->addError('A valid number is expected.', 1221563685);
            return;
        }

        $minimum = $this->options['minimum'];
        $maximum = $this->options['maximum'];
        if ($minimum > $maximum) {
            $x = $minimum;
            $minimum = $maximum;
            $maximum = $x;
        }
        if ($value < $minimum || $value > $maximum) {
            $this->addError('Please enter a valid number between %1$d and %2$d.', 1221561046, [$minimum, $maximum]);
        }
    }
593835
public function isValueValid($value) {
		return $value instanceof DataType\TextType || $value instanceof Type\ThingType || $value instanceof DataType\URLType;
	}