Framework: date_format validation rule behaving as if required

Created on 2 Sep 2016  路  3Comments  路  Source: laravel/framework

The date_format and after (probably before as well) validation rules are all behaving as if they are required.

If you pass in a null value, then all of these rules fail. In 5.2 they would pass.

They should pass in my opinion; if you want to disallow null values then you should also have the required rule.

Most helpful comment

null isn't an accepted value anymore, if you want a field to be nullable you need to pass the nullable rule.

['date' => 'nullable|after:2016-09-05']

This change was introduced in 5.3, and is documented in the upgrade guide briefly.

All 3 comments

null isn't an accepted value anymore, if you want a field to be nullable you need to pass the nullable rule.

['date' => 'nullable|after:2016-09-05']

This change was introduced in 5.3, and is documented in the upgrade guide briefly.

Thanks, I missed that, my fault.

No worries :)

Was this page helpful?
0 / 5 - 0 ratings