-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Set supportDateFormats() to "Y-m-d".
Currently you can pass "2025-01-0" as a date which will result in "2024-12-31 12:06:05.000000" as PHP doesn't validate this. Which is not what I expected. I'd like this to fail as "2025-01-0" is not a valid "Y-m-d" format.
I tried adding $date->format($format) === (string)$value to DateTimeFormatConstructor to validate that the source value is the same as the mapped value. But this results in multiple failed tests.
Perhaps we could add some "strict" mode to validate that the source value and mapped value are the same.
Afaik there's no way to "hook" into the mapping process to add custom validators, right? Which means I can't currently do anything about this without manually parsing the source and validating it before the mapping occurs.
Another idea (maybe should be another issue) is allowing different date types for different field. In my case I have a "birthday" field which should be "Y-m-d" while I might have another date in the same object with another format.