Enum
class Enum implements Rule, Stringable, ValidatorAwareRule
Traits
Properties
| protected Validator|null | $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. |
Methods
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.
Determine if the given case is a valid case based on the only / except values.
Get the validation error message.
Convert the rule to a validation string.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 43
__construct(string $type)
Create a new rule instance.
at line 51
bool
passes(string $attribute, mixed $value)
Determine if the validation rule passes.
at line 76
Enum
only(mixed $values)
Specify the cases that should be considered valid.
at line 88
Enum
except(mixed $values)
Specify the cases that should be considered invalid.
at line 98
protected bool
isDesirable(mixed $value)
Determine if the given case is a valid case based on the only / except values.
at line 110
array|string
message()
Get the validation error message.
at line 122
ValidatorAwareRule
setValidator(Validator $validator)
Set the current validator.
at line 132
string
__toString()
Convert the rule to a validation string.