date
and date-time
do not support formatMaximum
validation for years >=10000 🤷♂️
#61
Labels
date
and date-time
do not support formatMaximum
validation for years >=10000 🤷♂️
#61
When you create a
Date
object in UTC timezone in JavaScript as followsand convert it to ISO string, you get
+010000-01-01T00:00:00.000Z
(notice the leading+0
string).This seems to follow the ISO 8601 standard.
This breaks the
formatMaximum
(and possibly alsoformatMinimum
) validation because the dates are compared as plain strings, ie. eventually you get to a point where your compare"2018"
and"+010000"
and as far as JS strings are concerned,2018
is greater, even though the intention was to compare year 2018 and year 10000.Here, the ISO string is split into year component:
https://github.com/epoberezkin/ajv-keywords/blob/5f9eccc2e2b95745f659ef1abf5488f70da496f2/keywords/_formatLimit.js#L83-L87
And here is the actual string comparison of the two dates:
https://github.com/epoberezkin/ajv-keywords/blob/5f9eccc2e2b95745f659ef1abf5488f70da496f2/keywords/_formatLimit.js#L62-L67
The text was updated successfully, but these errors were encountered: