-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date-time format should use ISO 8601-1:2019 (same as System.Text.Json) #439
Comments
The JSON Schema spec, section 7.3.1 states RFC 3339. That's what this library uses. |
Is it possible to override the format validation to match with System.Text.Json? |
You can create your own The instructions are here. Also, you may want to read that whole section, as it describes how to enable format validation. Lastly, please be aware that providing date/time in a different format probably won't be compatible with other implementations, and you'll need to do this modification wherever you use this schema. |
This issue led me to look at the regex that was contributed to evaluate high-precision formats, and I discovered that that actually uses an ISO 8601 regex (which is what you were saying), which is wrong. I'll be updating that to support RFC3339. I'm also opening an issue with .Net for deserialization support. I wouldn't be surprised if they come back with, "You can create a custom converter for |
Thanks for the clarification on which spec should be used! For now, I overrode the validation in this lib to keep the same behavior as before (pre v4.0.1). I did it by creating a ISchemaRefiner class that replace the format intent to use my custom validation method. |
This was reported as a JsonSchema.Net issue, however Regardless, while I'm glad that you got something working for your case, I'm not sure that this is fully resolved since there is a disparity between .Net's date-time format expectations and JSON Schema's date-time requirements. |
@cdecroix please see the latest comment in the dotnet/runtime discussion linked above. It appears there is some format crossover that you might be able to take advantage of. |
Environment
Describe the bug
Values like "2023-03-20 05:41:23.3881075" ("T" missing between the date and time) are valid in JsonSchema but it can't be deserialized by System.Text.Json.
According to the Microsoft documentation, they parse date using the ISO 8601-1:2019 format.
The regex added to JsonSchema in v4.0.1 is based on the previous version of that ISO.
Expected behavior
Validation should return an error.
The text was updated successfully, but these errors were encountered: