0
votes

I'm using Laravel request validation rules to prevent two digit year entry from being interpreted as "00" plus the number. For example, my user entering "12" should be interpreted as "2012" and not "0012".

My validation rule is:

'monetary_statement_date' => 'nullable|after_or_equal:"1900-01-01"'

but this seems to be ignored (as is the rule "after").

I would expect a validation for any date that's prior to 1900, such as 0012, but it's not catching that. However, if I explicitly enter "1812" it works giving the message:

The monetary statement date must be a date after or equal to 1900-01-01.

So perhaps this is not the way to handle two-digit year entry. Any suggestions?

Working in Laravel 5.5 and Laragon.

1
Please show the exact data you are validating. - Severin

1 Answers

0
votes

Read this

Did you try after?

'monetary_statement_date' => 'after:"1900-01-01"'

also, try to remove nullable