1# When 2 3- `v::when(v $if, v $then, v $else)` 4- `v::when(v $if, v $then)` 5 6A ternary validator that accepts three parameters. 7 8When the `$if` validates, returns validation for `$then`. 9When the `$if` doesn't validate, returns validation for `$else`, if defined. 10 11```php 12v::when(v::intVal(), v::positive(), v::notEmpty())->validate($input); 13``` 14 15In the sample above, if `$input` is an integer, then it must be positive. 16If `$input` is not an integer, then it must not me empty. 17When `$else` is not defined use [AlwaysInvalid](AlwaysInvalid.md) 18 19*** 20See also: 21 22 * [AllOf](AllOf.md) 23 * [OneOf](OneOf.md) 24 * [NoneOf](NoneOf.md) 25