Skip to content

v4.2.0

Latest

Choose a tag to compare

@SoloPHP SoloPHP released this 28 Oct 14:06
7e0235b

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

  • null is no value. It meets only presence rules — required, filled, present, required_if, required_with… and any custom PresenceRule — and no longer fails string, email, min, in or any other rule that checks a value. A callback rule never sees it.
  • nullable keeps 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 before

Upgrading

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