Neos\Flow\Validation\Validator\NumberValidator::isValid PHP Méthode

isValid() protected méthode

Checks if the given value is a valid number.
protected isValid ( mixed $value ) : void
$value mixed The value that should be validated
Résultat void
    protected function isValid($value)
    {
        if (!isset($this->options['locale'])) {
            $locale = $this->localizationService->getConfiguration()->getDefaultLocale();
        } elseif (is_string($this->options['locale'])) {
            $locale = new I18n\Locale($this->options['locale']);
        } elseif ($this->options['locale'] instanceof I18n\Locale) {
            $locale = $this->options['locale'];
        } else {
            $this->addError('The "locale" option can be only set to string identifier, or Locale object.', 1281286579);
            return;
        }
        $strictMode = $this->options['strictMode'];
        $formatLength = $this->options['formatLength'];
        NumbersReader::validateFormatLength($formatLength);
        $formatType = $this->options['formatType'];
        NumbersReader::validateFormatType($formatType);
        if ($formatType === NumbersReader::FORMAT_TYPE_PERCENT) {
            if ($this->numberParser->parsePercentNumber($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid percent number is expected.', 1281452093);
            }
            return;
        } else {
            if ($this->numberParser->parseDecimalNumber($value, $locale, $formatLength, $strictMode) === false) {
                $this->addError('A valid decimal number is expected.', 1281452094);
            }
        }
    }
NumberValidator