Validates the input as one of the enum options maps the
value to an instance of the supplied enum class.

@param string $enumClass
@param string[] $valueLabelMap

@return FieldBuilderBase
@throws InvalidArgumentException
14433
public function enum(string $enumClass, array $valueLabelMap) : FieldBuilderBase
    {
        return $this->field->enum($enumClass, $valueLabelMap);
    }
461000
static function ensureValue($value)
    {
        if (!self::hasValue($value)) {
            throw new InvalidValueException(sprintf(
                'The value %s is not defined in enum class "%s", known values: %s',
                self::dumpValue($value),
                static::class,
                implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
            ));
        }
    }
856035
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $this->assertOptionsAreValid($options);

        foreach ($options['options'] as $i => $option) {
            if (!$option instanceof ProductOptionInterface) {
                throw new InvalidConfigurationException(
                    sprintf('Each object passed as option list must implement "%s"', ProductOptionInterface::class)
                );
            }

            $builder->add((string) $option->getCode(), ProductOptionValueChoiceType::class, [
                'label' => $option->getName() ?: $option->getCode(),
                'option' => $option,
                'property_path' => '[' . $i . ']',
                'block_name' => 'entry',
            ]);
        }
    }
843467
public function map(ValueObject $value): LanguageCreateData
    {
        if (!$value instanceof LanguageCreateStruct) {
            throw new InvalidArgumentException('value', 'must be an instance of ' . LanguageCreateStruct::class);
        }

        $data = new LanguageCreateData();

        $data->setName($value->name);
        $data->setLanguageCode($value->languageCode);
        $data->setEnabled($value->enabled);

        return $data;
    }
447840
public function addEnum(string $enumClass): void
    {
        $constantOriginalList = $this->getConstantList($enumClass);
        $constantCombineList = array_combine($constantOriginalList, $constantOriginalList);
        $constantCombineNormalizeList = array_change_key_case($constantCombineList, CASE_LOWER);

        $this->enumList[$enumClass] = [
            self::TYPE_ORIGINAL => $constantOriginalList,
            self::TYPE_COMBINE => $constantCombineList,
            self::TYPE_COMBINE_NORMALIZE => $constantCombineNormalizeList,
        ];
    }
1131941
public static <K extends Enum<K> & Keyed<V>, V> EnumLookup<K, V> of(final Class<K> enumClass) {
        return new EnumLookup<K, V>(enumClass, -1, false);
    }
335068
protected function _validateEnumValue($arg)
	{
		parent::_validateEnumValue($arg);
		$enum = strtoupper(trim($arg));
		if($enum !== 'ASC' && $enum !== 'DESC')
		{
			throw new \InvalidArgumentException('argument has to be a string of asc or desc!');
		}
		$this->enum = $enum;
	}
944034
public function isValid(ValidatorMap $map, $value)
    {
        switch ($map->getValue()) {
            case 'array':
                return is_array($value);
                break;
            case 'bool':
            case 'boolean':
                return is_bool($value);
                break;
            case 'float':
                return is_float($value);
                break;
            case 'int':
            case 'integer':
                return is_int($value);
                break;
            case 'numeric':
                return is_numeric($value);
                break;
            case 'object':
                return is_object($value);
                break;
            case 'resource':
                return is_resource($value);
                break;
            case 'scalar':
                return is_scalar($value);
                break;
            case 'string':
                return is_string($value);
                break;
            case 'function':
                return function_exists($value);
                break;
            default:
                throw new PropelException('Unknown type ' . $map->getValue());
                break;
        }
    }
363159
private <T extends Enum<T>> Object[] getValidEnumConstants(Class<T> valueClass) {
        T[] constants = valueClass.getEnumConstants();
        if (!VersionedEnum.class.isAssignableFrom(valueClass)) {
            return constants;
        }

        List<T> valid = new ArrayList<T>(constants.length);
        for (T value : constants) {
            VersionedEnum versionedValue = (VersionedEnum) value;
            if (version >= versionedValue.getMinVersion()) {
                valid.add(value);
            }
        }

        return valid.toArray();
    }
961061
public static function assertValidChoice(string $value): void
    {
        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM type "%s".', $value, static::class));
        }
    }
1303692
private function validateType($type, $value, $name = '')
    {
        $valueType = gettype($value);
        
        $codeException = $this->checkType($type, $value);
        
        if(1 === $codeException)
        {
            throw new InvalidArgumentException(sprintf('%s argument only accepts %s. Input type was: %s', $name, $type, $valueType));
        }
        
        if(2 === $codeException)
        {
            throw new RuntimeException('The argument is a resource, not is a valid type');
        }
        
        if(3 === $codeException)
        {
            throw new RuntimeException(sprintf('Value not defined in validation for %s', $type));
        }
        
        return $value;
    }
1003687
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return null;
        }

        if (!isset(static::$choices[$value])) {
            throw new \InvalidArgumentException(\sprintf('Invalid value "%s" for ENUM "%s".', $value, $this->getName()));
        }

        return $value;
    }
730908
public function setTypeMapping($type, $class = null)
    {
        if (is_string($type)) {
            if ($class === null) {
                throw new InvalidArgumentException(
                    'If $type is specified, $class is required'
                );
            }
            $type = array($type => (string) $class);
            $class = null;
        }

        if (!is_array($type)) {
            throw new InvalidArgumentException(
                'Type must either be an array or a string.'
            );
        }

        if ($class !== null) {
            throw new InvalidArgumentException(
                'If $type is an array, $class must not be specified.'
            );
        }

        $this->type_map = array_merge($this->type_map, $type);
    }
1133020
public function bindTo(string $valueObjectClass)
    {
        /** @var string|TypedObject $valueObjectClass */
        if (!is_subclass_of($valueObjectClass, IValueObject::class, true)) {
            throw InvalidArgumentException::format(
                'Invalid value object class supplied to %s: expecting subclass of %s, %s given',
                __METHOD__, IValueObject::class, $valueObjectClass
            );
        }

        $this->class = $valueObjectClass::definition();
    }
141898
public function map(Enum $enum, $value)
    {
        $this->checkType($enum);

        $this->valueMap[$enum->getConstName()] = $value;
        $this->mappedEnums[]                  = $enum;

        return $this;
    }
1211194
public <K, V> Map<K, V> asMap(@NonNull Class<?> mapClass, @NonNull Class<K> keyClass, @NonNull Class<V> valueClass) {
      return convert(toConvert, mapClass, keyClass, valueClass);
   }
882876
public static function fromValue($value)
    {
        $values = static::getValues();
        if (array_key_exists($value, $values)) {
            return new static($values[$value], $value);
        }
        throw new \InvalidArgumentException("No enum constant value '$value' class " . get_called_class());
    }