Repository navigation
A field with no value — absent, or null — is checked by presence rules only. 4.0 did this for an absent field; 4.2 reads a null the same way.
Changed
nullis no value. It meets only presence rules —required,filled,present,required_if,required_with… and any customPresenceRule— and no longer failsstring,email,min,inor any other rule that checks a value. A callback rule never sees it.nullablekeeps working and now matters only for''and[], which every rule checks without it, as before.
$validator->validate(['email' => null], ['email' => 'email']); // 4.1: email error, 4.2: []
$validator->validate(['email' => null], ['email' => 'filled|email']); // filled error, as before
$validator->validate(['email' => ''], ['email' => 'email']); // email error, as beforeUpgrading
A minor release with a behaviour change: projects on ^4.1 get it with composer update, and from then on a null passes the rules that check a value. Where a sent null must be refused, add filled — or required when the field must also be sent. A rule of your own that should see null has to implement PresenceRule. UPGRADE.md has the checklist.
Notes
- solophp/contracts 1.8 states the rule in
ValidatorInterfaceand conflicts with this package below 4.2. - solophp/input 1.1 relies on it to read a blank the type cannot hold as no value.