Skip to content
This repository was archived by the owner on Feb 1, 2019. It is now read-only.

Enforce Defaults option

Latest
Compare
Choose a tag to compare
@rsdoiel rsdoiel released this 17 Feb 19:09
· 12 commits to master since this release

The safer() function now has an enforceDefaults option. If true then keys defined in the validation map are will be returned with defaults values in the associative array from calls to safer().

     $a = safer([], [
        'i' => 'integer',
        'name' => 'text',
     ], false, true);
     print('i is ' . $a['i'] . ' (zero) and name is "' . $a['name'] . '" (an empty string)' . PHP_EOL);

This would display something like

    i is 0 (zero) and name is "" (an empty string)