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;
    }