class Enum implements Rule, ValidatorAwareRule (View source)
| Conditionable |
| protected class-string | $type | The type of the enum. | |
| protected Validator | $validator | The current validator instance. | |
| protected array | $only | The cases that should be considered valid. | |
| protected array | $except | The cases that should be considered invalid. |
| $this|TWhenReturnType | when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy. | from Conditionable |
| $this|TUnlessReturnType | unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy. | from Conditionable |
| void | __construct(class-string $type)
Create a new rule instance. | |
| bool | passes(string $attribute, mixed $value)
Determine if the validation rule passes. | |
| $this | only(UnitEnum[]|UnitEnum|UnitEnum> $values)
Specify the cases that should be considered valid. | |
| $this | except(UnitEnum[]|UnitEnum|UnitEnum> $values)
Specify the cases that should be considered invalid. | |
| bool | isDesirable(mixed $value)
Determine if the given case is a valid case based on the only / except values. | |
| string|array | message()
Get the validation error message. | |
| $this | setValidator(Validator $validator)
Set the current validator. |
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Create a new rule instance.
Determine if the validation rule passes.
Specify the cases that should be considered valid.
Specify the cases that should be considered invalid.
Determine if the given case is a valid case based on the only / except values.
Get the validation error message.
Set the current validator.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Validation/Rules/Enum.html