bug(LuxonDateAdapter): LuxonDateAdapter.parse() returns valid date even though none of the given input date formats is matched #25590
Labels
area: material/datepicker
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
No response
Description
The "parse" function in the LuxonDateAdapter tries to parse any input as a iso8601 date before it matches the given input formats.
For Example, if I declare ['d.L.yy', 'd-L-yy'] as valid input formats, I would expect that only dates using the separators "." and "-"
are valid input dates.
But due to the iso8601 parse a simple number input (eg. 12) will return a valid date, most times today.
You can see the iso8601 parse and return on line 162 of luxon-date-.adapter.ts
Where as the formats are checked later on line 174.
This parsing without any regard for the given input parseFormat seems to be incorrect.
Reproduction
There is test in luxon-date-adapter,spec.ts on line 310 which shows the behaviour . The input format is LL/dd/yyyy, but just a number is given.
Expected Behavior
The test mentioned above should return an invalid date, because the given parseFormat is not matched.
Actual Behavior
The function returns a valid ISO date, based on the number.
Environment
Above are the versios we are using in our code, but the code pasted in the description is from the current @angular/material-luxon-adapter, so the bug is still there.
The text was updated successfully, but these errors were encountered: