Validates that a value is equal to an empty string, empty array, false
or null
.
Check the NotBlank rule for the opposite validation.
Blank(
?callable $normalizer = null,
?string $message = null
);
Bellow are the only cases where the rule will succeed by default,
everything else is considered invalid (you may want to check the normalizer
option for a different behaviour):
Validator::blank()->validate(''); // true
Validator::blank()->validate([]); // true
Validator::blank()->validate(false); // true
Validator::blank()->validate(null); // true
type: ?callable
default: null
Allows to define a callable
that will be applied to the value before checking if it is valid.
For example, use trim
, or pass your own function, to allow a string with whitespaces only:
Validator::blank(normalizer: 'trim')->validate(' '); // true
Validator::blank(normalizer: fn($value) => trim($value))->validate(' '); // true
type: ?string
default: The {{ name }} value should be blank.
Message that will be shown if the value is not blank.
The following parameters are available:
Parameter | Description |
---|---|
{{ value }} |
The current invalid value |
{{ name }} |
Name of the invalid value |
1.2.0
Created