2015-10-07 07:41:38 +02:00
|
|
|
# Optional
|
|
|
|
|
2017-03-27 14:47:07 +02:00
|
|
|
- `Optional(Validatable $rule)`
|
2015-10-07 07:41:38 +02:00
|
|
|
|
2015-10-15 16:10:47 +02:00
|
|
|
Validates if the given input is optional or not. By _optional_ we consider `null`
|
|
|
|
or an empty string (`''`).
|
2015-10-07 07:41:38 +02:00
|
|
|
|
|
|
|
```php
|
|
|
|
v::optional(v::alpha())->validate(''); // true
|
|
|
|
v::optional(v::digit())->validate(null); // true
|
|
|
|
```
|
|
|
|
|
2019-05-11 18:32:13 +02:00
|
|
|
## Categorization
|
|
|
|
|
|
|
|
- Nesting
|
|
|
|
|
2017-03-27 22:04:13 +02:00
|
|
|
## Changelog
|
|
|
|
|
|
|
|
Version | Description
|
|
|
|
--------|-------------
|
|
|
|
1.0.0 | Created
|
2015-10-07 07:41:38 +02:00
|
|
|
|
|
|
|
***
|
|
|
|
See also:
|
|
|
|
|
2017-03-28 11:53:14 +02:00
|
|
|
- [NoWhitespace](NoWhitespace.md)
|
|
|
|
- [NotBlank](NotBlank.md)
|
|
|
|
- [NotEmpty](NotEmpty.md)
|
|
|
|
- [NotOptional](NotOptional.md)
|
|
|
|
- [NullType](NullType.md)
|
2018-12-11 13:31:50 +01:00
|
|
|
- [Nullable](Nullable.md)
|