Validates provided format type and throws exception if value is not
allowed.

@param string $formatType
@return void
@throws Exception\InvalidFormatTypeException When value is unallowed
553652
public static function validateFormatType($formatType)
    {
        if (!in_array($formatType, [self::FORMAT_TYPE_DECIMAL, self::FORMAT_TYPE_PERCENT, self::FORMAT_TYPE_CURRENCY])) {
            throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281439179);
        }
    }
578740
public static function toNumeric($formatType = 'none')
    {
        if (!is_string($formatType)) {
            throw new \InvalidArgumentException('The app type "' . $formatType . '" is not a string.');
        }

        return static::defines(strtoupper($formatType), true);
    }
945160
public function setType($type)
    {
        if (gettype($type) === 'string') {
            $this->type = $type;
        } else {
            $msg = "Type must be a string, '" . gettype($type) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
617628
protected function validate($value)
    {
        foreach ($this->validators as $validator) {
            if (!$validator->validate($value)) {
                throw new InvalidValueException(
                    "Field {$this->name}, was set with invalid value: " . var_export($value, true)
                );
            }
        }
    }
1114475
protected function validateFormat($format, Serializer $serializer)
    {
        if(false == $format) {
            throw new \InvalidArgumentException('Mandatory field "format" is missing in the given configuration');
        }

        if (false == $serializer->supportsEncoding($format)) {
            throw new \InvalidArgumentException(sprintf(
                'Given format "%s" is not supported by serializer',
                $format
            ));
        }
    }
277421
private function validateType($type)
    {
        if (!in_array($type, self::$validTypes)) {
            throw new InvalidMappingException(
                'Invalid uploadable field type reference. Must be one of: '.implode(', ', self::$validTypes)
            );
        }
    }
1097424
protected function setType(string $type) : void
    {
        if (empty($type)) {
            throw new InvalidArgumentException(__CLASS__ . ': Empty field type is not allowed');
        }

        if (! in_array($type, array_keys($this->defaultOptions))) {
            throw new InvalidArgumentException(__CLASS__ . ': Unsupported field type: ' . $type);
        }

        $this->type = $type;
    }
340232
protected function checkFormat($format, $type = null)
    {
        return !is_null($format) ? $format : $this->getFormat($type);
    }
681641
private function checkType(&$type)
    {
        if ( ! is_string($type)) {
            throw new InvalidTwitterCardException(
                'The Twitter card type must be a string value, [' . gettype($type) . '] was given.'
            );
        }

        $type = strtolower(trim($type));

        if ( ! in_array($type, $this->types())) {
            throw new InvalidTwitterCardException("The Twitter card type [$type] is not supported.");
        }
    }
112705
private function isValidAudienceType(string $audienceType): void
    {
        $allowedAudienceType = $this->getAllowedAudienceType();
        if (!\in_array($audienceType, $allowedAudienceType, true)) {
            throw new InvalidTypeException(sprintf(
                'audienceType must be either "%s".',
                implode(', ', $allowedAudienceType)
            ));
        }
    }
1143460
public function setFormFieldType($formFieldType)
    {
        if (!is_string($formFieldType) || $formFieldType === '') {
            throw new InvalidArgumentException('"Form field type" argument must be a string and must not empty.');
        }

        $this->formFieldType = $formFieldType;

        return $this;
    }
1067999
public function setGroupFormat($query_name, $format_type, $format_value)
    {

        $this->checkGroupName("set_group_format", $query_name);
        if (array_key_exists($query_name, $this->group)) {
            $col = &$this->group[$query_name];
            $col->setFormat($format_type, $format_value);
        }
    }
558448
public function setSingleType($singleType)
    {
        $allowedTypes = [
            self::SINGLE_TYPE_EXACT,
            self::SINGLE_TYPE_GREATER,
            self::SINGLE_TYPE_GREATER_OR_EQUAL,
            self::SINGLE_TYPE_LESS,
            self::SINGLE_TYPE_LESS_OR_EQUAL,
        ];

        if (!is_string($singleType) || !in_array($singleType, $allowedTypes, true)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid "single type" argument. Allowed types: [%s].', implode(', ', $allowedTypes)
            ));
        }

        $this->singleType = $singleType;

        return $this;
    }
766251
public function validateForm()
    {
        $validator = $this->getValidationFactory()->make(
            $this->requestData(),
            $this->rules()
        );

        if ($validator->fails())
            throw new \Exception($this->formatErrors($validator->errors()));
    }
964439
public function validate() {

		if ($this->getExternalId() === null) {
			throw new ValidationException("'externalId' can't be null", 'externalId', $this);
		}
		if ($this->getProcessingType() === null) {
			throw new ValidationException("'processingType' can't be null", 'processingType', $this);
		}
		if ($this->getSubscription() === null) {
			throw new ValidationException("'subscription' can't be null", 'subscription', $this);
		}
	}
73661
private function isValidMediaType($mediaType): void
    {
        $allowedMediaType = $this->getAllowedMediaType();
        if (!\in_array($mediaType, $allowedMediaType, true)) {
            throw new InvalidTypeException(sprintf(
                'mediaType must be either "%s".',
                implode(', ', $allowedMediaType)
            ));
        }
    }
1146015
public static function validateFormatLength($formatLength)
    {
        if (!in_array($formatLength, [self::FORMAT_LENGTH_DEFAULT, self::FORMAT_LENGTH_FULL, self::FORMAT_LENGTH_LONG, self::FORMAT_LENGTH_MEDIUM, self::FORMAT_LENGTH_SHORT])) {
            throw new Exception\InvalidFormatLengthException('Provided formatLength, "' . $formatLength . '", is not one of allowed values.', 1281442591);
        }
    }