-
-
Notifications
You must be signed in to change notification settings - Fork 37
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 accepts timestamps without "T"
separator between date and time
#55
Comments
Is this required? The use of space for the sake of readability seems to indicate that it is acceptable.
|
@sei-vsarvepalli I think this is the right move as it differentiates between "iso8601" and "rfc3339". Also the ABNF clearly states in RFC 3339 Section 5.6:
And:
(emphasis by me) So with regard to CSAF, I think it makes sense to limit this to the one standard way. |
@tschmidtb51
On the ajv regex recommended by @jan-san , all of these below examples parse okay with the ajv library, where the item 4 should not if you follow the RFC.
|
True. I guess the more precise regex is:
|
According to the JSON Schema Validation spec, section 7.3.1 and ajv-formats' documentation, the
date-time
format should validate a string against thedate-time
production of RFC 3339, section 5.6.This production requires the date and time components to be separated by
"T"
or"t"
.The validation regex used in ajv-formats 2.1.1 however also accepts strings like
"2023-01-22 11:11:11.123"
with a whitespace character separating the date and time components (note the[t\s]
portion):/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i
This issue will be addressed in version 3. I am posting this issue for troubleshooting/documentation.
A workaround for ajv-formats 2.1.1 is to add a
pattern()
to the schema, e.g. using a slight variation of the regular expression used in ajv-formats 3:The text was updated successfully, but these errors were encountered: