You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second case just shortens the year to three digits, I suspect that something in the engine automatically detects the ISO datetime in the value and prevents the match. Note that the pattern in the schema is stricter than `"format": "date-time" which is why I can't use the latter in my particular use case.
The text was updated successfully, but these errors were encountered:
hannes-ucsc
changed the title
Strings matching ISO time fail to match explicit pattern
Strings matching ISO datetime fail to match explicit pattern
Mar 24, 2022
I agree with the suspicion that Json.Newtonsoft.Schema (or Newtonsoft.Json) is somewhere somehow unwarrantedly trying to roundtrip the string as a DateTime (or similar) and back to a string.
I think this is why your first example fails: Note the trailing insignificant 0 at the fractions of seconds "2020-05-01T04:26:07.021870Z". This string, when roundtripped through DateTime, could result in the string "2020-05-01T04:26:07.02187Z", thus the regex pattern will not match.
Empirical evidence supporting my theory/suspicion:
If you change the regex pattern in your first example to match 5 digits for fractions of seconds the json will be incorrectly validated successfully: https://www.jsonschemavalidator.net/s/bmTXmWg2
If you change the insignificant 0 in the fractions of seconds to a significant (non-zero) digit while keeping your original regex pattern then the json will be (accidentally) correctly validated successfully: https://www.jsonschemavalidator.net/s/adTgPajW
It should be possible to work-around this bug in your own code by using an appropriately configured JsonReader (JsonReader.DateParseHandling) to read the json data.
For the online validator this would mean an update to the code backing this service, and until this happens the online validator is unfortunately essentially unreliable.
I expect both to validate but only the latter one does.
https://www.jsonschemavalidator.net/s/aGIeEynR
https://www.jsonschemavalidator.net/s/v9Or7B17
The second case just shortens the year to three digits, I suspect that something in the engine automatically detects the ISO datetime in the value and prevents the match. Note that the pattern in the schema is stricter than `"format": "date-time" which is why I can't use the latter in my particular use case.
The text was updated successfully, but these errors were encountered: