tao-test/app/vendor/respect/validation/docs/rules/Optional.md

22 lines
426 B
Markdown
Raw Normal View History

2022-08-29 20:14:13 +02:00
# Optional
- `v::optional(v $rule)`
Validates if the given input is optional or not. By _optional_ we consider `null`
or an empty string (`''`).
```php
v::optional(v::alpha())->validate(''); // true
v::optional(v::digit())->validate(null); // true
```
***
See also:
* [NoWhitespace](NoWhitespace.md)
* [NotBlank](NotBlank.md)
* [NotEmpty](NotEmpty.md)
* [NotOptional](NotOptional.md)
* [NullType](NullType.md)