I am trying to validate a date field only if it is present. It was working fine before I upgraded from Laravel 5.2 to 5.4
In Laravel 5.2 this rules works fine:
public function rules()
{
return [
'available_from' => 'date',
];
}
In 5.4 it returns validation error The available from is not a valid date.
I tried this new rules
public function rules()
{
return [
'available_from' => 'sometimes|date',
];
}
Still got the same error and seems the sometimes
rules not affecting the validation at all. How can I get rid of this error?
I don't understand why Laravel changed something that was working before!!!
YYYY-MM-DD
– Flavouring