src/Schema.php
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;
    }
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;
    }
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 ; }
Validate a value against an enum.

@param mixed $value The value to test.
@param ValidationField $field The validation object for adding errors.
@return mixed|Invalid Returns the value if it is one of the enumerated values or invalid otherwise.
Validate a value against an enum .