Flerex
2 weeks ago

Slashes on date format in Validator not working

Posted 2 weeks ago by Flerex

I'm trying to validate a date in d/m/Y format, like for example 20/10/1990. But, for some reason the following code does not pass:

$validator = Validator::make(['my-date' => '20/10/1990'], [
	'my-date' => ['date', 'date_format:d/m/Y']

$validator->fails(); // true, should be false

However, the following code indeed does work, and I'm only changing the slashes for dashes.

$validator = Validator::make(['my-date' => '20-10-1990'], [
	'my-date' => ['date', 'date_format:d-m-Y']

$validator->fails(); // false

Any idea why this is not working as expected?

Please sign in or create an account to participate in this conversation.