Validate the enum value and set the enum property to the validated value.

The validated value will returned from the __toString() method after the value objects initialization.

@param string $arg
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;
	}
399632
protected function validateEnum($value, ValidationField $field) {
        $enum = $field->val('enum');
        if (empty($enum)) {
            return $value;
        }

        if (!in_array($value, $enum, true)) {
            $field->addError(
                'enum',
                [
                    'messageCode' => 'The value must be one of: {enum}.',
                    'enum' => $enum,
                ]
            );
            return Invalid::value();
        }
        return $value;
    }
86605
private function fill(array $args)
    {
        $properties = array_keys(get_object_vars($this));
        foreach ($args as $key => $value) {
            if (in_array($key, $properties)) {
                $this->{$key} = $value;
            }
        }
    }
1231065
public static function validate($value)
    {
        $reflector = new ReflectionClass(static::class);

        foreach ($reflector->getConstants() as $allowedValue) {
            if ($value === $allowedValue) {
                return $allowedValue;
            }
        }

        throw new ArgumentException(
            sprintf(
                'Invalid value `%s` on enum `%s`',
                $value,
                static::class
            )
        );
    }
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));
        }
    }
194675
protected function _validateArgs(array $args): bool {
        foreach (self::REQUIRED_FLAGS as $flag) {
            if (!array_key_exists($flag, $args)) {
                Garp_Cli::errorOut("No {$flag} flag provided.");
                return false;
            }
        }
        return true;
    }
341129
public function validate($str)
    {
        if ($str === null) {
            throw new \InvalidArgumentException('Error: String must not be null');
        }
        if (! is_string($str)) {
            throw new \InvalidArgumentException(
                'Error: String must be of type string but is of type "'.gettype($str).'"'
            );
        }
        if ($str === '') {
            throw new \InvalidArgumentException('Error: String must not be empty');
        }
        if ($this->containsMultibyteChar($str)) {
            throw new \InvalidArgumentException('Error: String must not contain any multibyte characters');
        }
    }
897886
private function prepareType($arg){
        if(($arg===null || $arg=='null') && $arg !== 0){
            return 'NULL';
        }//if
        if(!is_numeric($arg)){
            return $this->quote($arg);
        }//if
        return $arg;
    }
98010
protected function setArgumentValue($argv, $argument, $key, $value)
    {
        // Arguments are given the value true if they only need to
        // be defined on the command line to be set.
        if ($argument->noValue()) {
            $argument->setValue(true);
            return $argv;
        }

        if (is_null($value)) {
            if (count($argv) === 0) {
                return $argv;
            }

            // If the value wasn't previously defined in "key=value"
            // format then define it from the next command argument.
            $nextArgvValue = $argv[$key + 1];
            if ($this->isValidArgumentValue($nextArgvValue)) {
                $argument->setValue($nextArgvValue);
                unset($argv[$key + 1]);
                return $argv;
            }
        }

        $argument->setValue($value);

        return $argv;
    }
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }
675176
protected function processArgumentBoolean(Element $arg) {
		$definition = new stdClass();
		$definition->type = 'value';
		
		if (isset($arg->value)) {
			$definition->value = (trim($arg->value) === 'true');
			return $definition;
		}
		
		$value = $arg->getValue();
		
		if (! empty($value)) {
			$definition->value = (trim($value) === 'true');
			return $definition;
		}
		
		throw new InvalidConfig('Definition of an argument type "boolean" must contain a value as content or the "value" attribute', null, null, $arg);
	}
702099
public static function setOptionalValue( Option &$option, $arg )
    {
        if ( !self::isShortCode( $arg ) && !self::isLongCode( $arg ) )
        {
            if ( is_bool( $arg ) )
            {
                $option->value = ( bool )$arg;
            }
            elseif ( is_string( $arg ) )
            {
                $arg = trim( $arg );
            
                $option->value = $arg;
            }
        }
    }
72415
protected function checkValue(): void
    {
        if (!ctype_digit($this->value) && !is_numeric($this->value) && !empty($this->value)) {
            throw new InvalidArgumentException('NumericParser: Value must be of type numeric');
        }
    }
743231
protected void addArg(Object value) {
        if (value instanceof Enum) {
            value = ((Enum<?>) value).name();
        }
        args.add(value);
    }
771816
public function beforeInsert(&$args) {
        $model = &$args[0];
        $data  = &$args[1];
        $this->validate($data, $model);
    }
433934
protected function setEnum($enum)
    {
        if ($enum === null) {
            $enum = $this->default;
        }

        if (!\array_key_exists($enum, $this->enumsReversed)) {
            throw new \UnexpectedValueException("Enum '{$enum}' does not exist");
        }

        $this->enum = $enum;

        return $this;
    }
688572
public static function argValue(ArgumentNode $arg, $default = null)
    {
        $valueNode = $arg->value;

        if (! $valueNode) {
            return $default;
        }

        return AST::valueFromASTUntyped($valueNode);
    }