validateFormatLength() public static method

Validates provided format length and throws exception if value is not allowed.
public static validateFormatLength ( string $formatLength ) : void
$formatLength string
return void
 /**
  * Checks if the given value is a valid number.
  *
  * @param mixed $value The value that should be validated
  * @return void
  * @api
  * @todo Currency support should be added when it will be supported by NumberParser
  */
 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);
         }
     }
 }
 /**
  * Formats number with format string for currency defined in CLDR for
  * particular locale.
  *
  * Currency symbol provided will be inserted into formatted number string.
  *
  * Note: currently length is not used in currencyFormats from CLDR.
  * But it's defined in the specification, so we support it here.
  *
  * @param mixed $number Float or int, can be negative, can be NaN or infinite
  * @param Locale $locale
  * @param string $currency Currency symbol (or name)
  * @param string $formatLength One of NumbersReader FORMAT_LENGTH constants
  * @return string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength
  * @api
  */
 public function formatCurrencyNumber($number, Locale $locale, $currency, $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT)
 {
     NumbersReader::validateFormatLength($formatLength);
     return $this->doFormattingWithParsedFormat($number, $this->numbersReader->parseFormatFromCldr($locale, NumbersReader::FORMAT_TYPE_CURRENCY, $formatLength), $this->numbersReader->getLocalizedSymbolsForLocale($locale), $currency);
 }
 /**
  * Tries to parse the input using the NumberParser.
  *
  * @param string $source
  * @param PropertyMappingConfigurationInterface $configuration
  * @return float|\Neos\Flow\Validation\Error Parsed float number or error
  * @throws \Neos\Flow\Property\Exception\InvalidPropertyMappingConfigurationException
  */
 protected function parseUsingLocaleIfConfigured($source, PropertyMappingConfigurationInterface $configuration)
 {
     $configuration = $this->getConfigurationKeysAndValues($configuration, ['locale', 'strictMode', 'formatLength', 'formatType']);
     if ($configuration['locale'] === null) {
         return $source;
     } elseif ($configuration['locale'] === true) {
         $locale = $this->localizationService->getConfiguration()->getCurrentLocale();
     } elseif (is_string($configuration['locale'])) {
         $locale = new Locale($configuration['locale']);
     } elseif ($configuration['locale'] instanceof Locale) {
         $locale = $configuration['locale'];
     }
     if (!$locale instanceof Locale) {
         $exceptionMessage = 'Determined locale is not of type "\\Neos\\Flow\\I18n\\Locale", but of type "' . (is_object($locale) ? get_class($locale) : gettype($locale)) . '".';
         throw new InvalidPropertyMappingConfigurationException($exceptionMessage, 1334837413);
     }
     if ($configuration['strictMode'] === null || $configuration['strictMode'] === true) {
         $strictMode = true;
     } else {
         $strictMode = false;
     }
     if ($configuration['formatLength'] !== null) {
         $formatLength = $configuration['formatLength'];
         NumbersReader::validateFormatLength($formatLength);
     } else {
         $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT;
     }
     if ($configuration['formatType'] !== null) {
         $formatType = $configuration['formatType'];
         NumbersReader::validateFormatType($formatType);
     } else {
         $formatType = NumbersReader::FORMAT_TYPE_DECIMAL;
     }
     if ($formatType === NumbersReader::FORMAT_TYPE_PERCENT) {
         $return = $this->numberParser->parsePercentNumber($source, $locale, $formatLength, $strictMode);
         if ($return === false) {
             $return = new Error('A valid percent number is expected.', 1334839253);
         }
     } else {
         $return = $this->numberParser->parseDecimalNumber($source, $locale, $formatLength, $strictMode);
         if ($return === false) {
             $return = new Error('A valid decimal number is expected.', 1334839260);
         }
     }
     return $return;
 }
 /**
  * Parses percent number using proper format from CLDR.
  *
  * @param string $numberToParse Number to be parsed
  * @param Locale $locale Locale to use
  * @param string $formatLength One of NumbersReader FORMAT_LENGTH constants
  * @param boolean $strictMode Work mode (strict when TRUE, lenient when FALSE)
  * @return mixed Parsed float number or FALSE on failure
  * @api
  */
 public function parsePercentNumber($numberToParse, Locale $locale, $formatLength = NumbersReader::FORMAT_LENGTH_DEFAULT, $strictMode = true)
 {
     NumbersReader::validateFormatLength($formatLength);
     return $this->doParsingWithParsedFormat($numberToParse, $this->numbersReader->parseFormatFromCldr($locale, NumbersReader::FORMAT_TYPE_PERCENT, $formatLength), $this->numbersReader->getLocalizedSymbolsForLocale($locale), $strictMode);
 }