Enum
class Enum implements Rule, ValidatorAwareRule (View source)
Traits
Properties
| 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.  | 
                
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.
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.
Details
        
                            $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.
        
                            $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.
        
                            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.
        
                    protected        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.