Validate that a string is a number formatted correctly for the current locale.
@param string $x a string
@return bool whether $x is a number that the numerical question type can interpret.
493505
public static function is_valid_number(string $x) : bool {
        $ap = new qtype_numerical_answer_processor(array());
        list($value, $unit) = $ap->apply_units($x);
        return !is_null($value) && !$unit;
    }
572845
public function isValid($value)
    {
        if (!is_scalar($value) || !is_numeric($value)) {
            $this->error(self::INVALID);

            return false;
        }

        $length = strlen($value);

        if ($length < 9) {
            $this->error(self::TOO_SHORT);

            return false;
        }

        if ($length > 9) {
            $this->error(self::TOO_LONG);

            return false;
        }

        if (!parent::isValid($value)) {
            $this->error(self::NO_MATCH);

            return false;
        }

        preg_match($this->pattern, $value, $matches);

        // check for EIN prefixes
        $intPrefix = (int) $matches[1];

        foreach ($this->prefix as $check) {
            if ($intPrefix >= $check[0] && $intPrefix <= $check[1]) {
                return true;
            }
        }

        $this->error(self::NO_MATCH);

        return false;
    }
979921
public static function match($phone='') {
		if (! \is_string($phone)) {
			if (\is_numeric($phone)) {
				$phone = (string) $phone;
			}
			else {
				return false;
			}
		}

		phone::sanitize_phone($phone);
		if (false === $phone) {
			return false;
		}

		// Test the number with and without the prefix.
		$test = array($phone);
		$tmp = \ltrim($phone, '0');
		if (0 === \strpos($tmp, \strval(static::PREFIX))) {
			$test[] = \substr($tmp, \strlen(static::PREFIX));
		}

		// Do they match the patterns?
		foreach ($test as $t) {
			foreach (static::PATTERNS as $p) {
				if (\preg_match("/^($p)$/", $t)) {
					// Should match a specific type.
					$types = static::types($t);
					if (! \count($types)) {
						continue;
					}

					$out = phone::TEMPLATE;
					$out['country'] = static::CODE;
					$out['prefix'] = static::PREFIX;
					$out['region'] = static::REGION;
					$out['types'] = $types;
					$out['number'] = '+' . static::PREFIX . ' ' . static::format($t);

					return $out;
				}
			}
		}

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

        $value = (string) $value;
        $this->_setValue($value);

        switch ($this->_detectFormat()) {
            case self::ISBN10:
                // sum
                $isbn10 = str_replace($this->_separator, '', $value);
                $sum    = 0;
                for ($i = 0; $i < 9; $i++) {
                    $sum += (10 - $i) * $isbn10{$i};
                }

                // checksum
                $checksum = 11 - ($sum % 11);
                if ($checksum == 11) {
                    $checksum = '0';
                } elseif ($checksum == 10) {
                    $checksum = 'X';
                }
                break;

            case self::ISBN13:
                // sum
                $isbn13 = str_replace($this->_separator, '', $value);
                $sum    = 0;
                for ($i = 0; $i < 12; $i++) {
                    if ($i % 2 == 0) {
                        $sum += $isbn13{$i};
                    } else {
                        $sum += 3 * $isbn13{$i};
                    }
                }
                // checksum
                $checksum = 10 - ($sum % 10);
                if ($checksum == 10) {
                    $checksum = '0';
                }
                break;

            default:
                $this->_error(self::NO_ISBN);
                return false;
        }

        // validate
        if (substr($this->_value, -1) != $checksum) {
            $this->_error(self::NO_ISBN);
            return false;
        }
        return true;
    }
601525
protected function validate(string $input): bool
    {
        return preg_match($this->realNumber ? self::REAL_NUMBER_REGEXP : self::INTEGER_REGEXP, $input) === 1;
    }
955368
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

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

        return true;
    }
266463
protected function validate($value){
        if( parent::validate($value) ){
            $length = mb_strlen($value, 'utf-8');
            if( $this->min && $this->min > $length ){
                throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and more.'), $this->label, $this->min));
            }
            if( $this->max &&  $this->max < $length ){
                throw new ValidateException(sprintf($this->__('Fields %s must be %d digits and fewer.'), $this->label, $this->max));
            }
        }
        return true;
    }
213807
public function valid( $x, $y )
    {
        return ($x > 0 && $x < $this->getWidth() && $y > 0 && $y < $this->getHeight());
    }
1121055
public function lt($number)
    {
        return (bool) (bccomp($this->number, static::validateInputNumber($number), $this->precision) === -1);
    }
927670
public function validateRegexp()
    {
        $val = $this->val();

        $regexp = $this->regexp();
        if ($regexp == '') {
            return true;
        }

        $valid = !!preg_match($regexp, $val);
        if (!$valid) {
            $this->validator()->error('Regexp error', 'regexp');
        }

        return $valid;
    }
1170195
public function isValid($value)
    {
        if (!preg_match('/^\+?[0-9]{2,12}$/', $value)) {
            $this->error(self::BAD_SYNTAX);
            return false;
        }
        
        return true;
    }
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;
    }
376040
public function isValueValid($value) {
		return $value instanceof DataType\NumberType || $value instanceof Type\PriceSpecification || $value instanceof DataType\TextType;
	}
1050595
public static function validate($value)
    {
        if (!is_numeric($value)) {
            return false;
        }

        $stringLength = strlen($value);

        if ($stringLength !== 9 && $stringLength !== 8) {
            return false;
        }

        $sum = 0;
        $multiplier = $stringLength;
        for ($counter = 0; $counter < $stringLength; $counter++, $multiplier--) {
            if ($multiplier == 1) {
                $multiplier = -1;
            }

            $sum += substr($value, $counter, 1) * $multiplier;
        }

        return $sum % 11 === 0;
    }
649682
public function validateXML($xml)
    {
        $xmlValidator = new XMLValidator();
        $result = $xmlValidator->validateSchemaVersion($xml);
        if ($result === false) {
            $this->setResponse("verbosemessage", $xmlValidator->getValidationMessage());
            return false;
        }
        return true;
    }
687108
public static function isStreetNumber($string) {
        static $pattern = '/^[0-9A-Za-z-\/]+$/';
        return is_string($string) && strlen($string) && preg_match($pattern, strtolower($string));
    }
96204
public function isValueValid($value) {
		return $value instanceof DataType\NumberType || $value instanceof Type\QuantitativeValue || $value instanceof DataType\TextType;
	}