Skip to content

Commit a582745

Browse files
committed
Add documentation for FilterOptions::RETURN_ON_NULL
1 parent 008b96f commit a582745

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,42 @@ $specification = [
409409

410410
If the `id` value given in the input is not an integer the Filterer::execute() will throw the `NotFoundException`
411411

412+
## returnOnNull
413+
414+
#### Summary
415+
416+
Flag to break the filter chain if a resulting value is `null` Useful for nullable fields which require additional filtering if the value is not null.
417+
418+
#### Types
419+
420+
* boolean
421+
422+
#### Default
423+
424+
The default value for this option is `false`
425+
426+
#### Constant
427+
428+
```php
429+
TraderInteractive\FilterOptions::RETURN_ON_NULL
430+
```
431+
432+
#### Example
433+
434+
```php
435+
$validCodes = ['A', 'I', 'X'];
436+
$specification = [
437+
'code' => [
438+
\TraderInteractive\FilterOptions::RETURN_ON_NULL => true,
439+
['string', true],
440+
['strtoupper'],
441+
['in', $validCodes],
442+
],
443+
];
444+
```
445+
446+
If the `code` value is `null` then the resulting filtered value will be null. Otherwise the value must be one of the `$validCode` values.
447+
412448
### Included Filters
413449
Of course, any function can potentially be used as a filter, but we include some useful filters with aliases for common circumstances.
414450

0 commit comments

Comments
 (0)