mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
The "NotBlank", "NotEmpty", and "NotUndef" rules do not display the input in all cases and instead displays the string "The value". The problem with that is that one doesn't see which value was passed, which is not so useful. This commit will changes those rules to always display the input. If someone doesn't want the input to show, they can always set a name for the rule.
1.7 KiB
1.7 KiB
NotUndef
NotUndef()
Validates if the given input is not optional. By optional we consider null
or an empty string ('').
v::notUndef()->isValid(''); // false
v::notUndef()->isValid(null); // false
Other values:
v::notUndef()->isValid([]); // true
v::notUndef()->isValid(' '); // true
v::notUndef()->isValid(0); // true
v::notUndef()->isValid('0'); // true
v::notUndef()->isValid(0); // true
v::notUndef()->isValid('0.0'); // true
v::notUndef()->isValid(false); // true
v::notUndef()->isValid(['']); // true
v::notUndef()->isValid([' ']); // true
v::notUndef()->isValid([0]); // true
v::notUndef()->isValid(['0']); // true
v::notUndef()->isValid([false]); // true
v::notUndef()->isValid([[''), [0]]); // true
v::notUndef()->isValid(new stdClass()); // true
Templates
NotUndef::TEMPLATE_STANDARD
| Mode | Template |
|---|---|
default |
{{name}} must be defined |
inverted |
{{name}} must be undefined |
Template placeholders
| Placeholder | Description |
|---|---|
name |
The validated input or the custom validator name (if specified). |
Categorization
- Miscellaneous
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Renamed from "NotOptional" to "NotUndef" |
| 1.0.0 | Created |
See also: