minimum / maximum for strings #445
samgqroberts
started this conversation in
Specification
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, sorry if this has already been covered but I couldn't find a discussion for it.
The question
Could we add "minimum" and "maximum"-like keywords for strings?
This would be lexicographic ordering.
Or asked another way: has there been discussion around this, and if so what are the reasons for not including them? (Also, they don't have to be called "minimum" and "maximum" in order to not collide with the numeric keywords. Perhaps "minValue" / "maxValue"?)
Example applications
date / date-time
The "date" and "date-time" formats conform to RFC3339 which was designed, in part, to have lexicographical order correspond with chronological order. Eg.
2023-07-13
is lexicographically less than2023-07-14
and therefore can be known to be chronologically less than as well, since both conform to the ISO-8601 date format.Defining a type like
{"type": "string", "format": "date", "minimum": "2023-07-13"}
would semantically mean "any date chronologically after July 13, 2023, inclusive," which seems like a very natural thing to want to say about dates.Beta Was this translation helpful? Give feedback.
All reactions