mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 07:45:45 +01:00
Since we have the ability to use `not` as a prefix, having rules that start with not becomes a bit inflexible, verbose, and harder to understand. This commit will refactor the `NotBlank` rule by inverting its behaviour and renaming it to `Blank`. Although this is a breaking change, users will not feel it because "NotBlank" will still be available by using the `not` prefix followed by the `Blank` rule.
1.5 KiB
1.5 KiB
NotEmpty
NotEmpty()
Validates wether the given input is not empty. This function also takes whitespace
into account, use noWhitespace() if no spaces or linebreaks and other
whitespace anywhere in the input is desired.
v::stringType()->notEmpty()->isValid(''); // false
Null values are empty:
v::notEmpty()->isValid(null); // false
Numbers:
v::intVal()->notEmpty()->isValid(0); // false
Empty arrays:
v::arrayVal()->notEmpty()->isValid([]); // false
Whitespace:
v::stringType()->notEmpty()->isValid(' '); //false
v::stringType()->notEmpty()->isValid("\t \n \r"); //false
Templates
NotEmpty::TEMPLATE_STANDARD
| Mode | Template |
|---|---|
default |
{{subject}} must not be empty |
inverted |
{{subject}} must be empty |
Template placeholders
| Placeholder | Description |
|---|---|
subject |
The validated input or the custom validator name (if specified). |
Categorization
- Miscellaneous
Changelog
| Version | Description |
|---|---|
| 0.3.9 | Created |
See also: