JSON Schema seems to support ISO times, dates, date-times, and even durations (see documentation), but I can't find anyway to support ISO time ranges.
I could use regex (which JSON Schema does support) but then I wouldn't be able to check if the start and end points of the interval were actually valid dates/times (e.g. 2022-13-04 there is no 13th month). How should I proceed? Do I just have to accept any string and do the validation in the JSON consuming application?
CodePudding user response:
String formats aren't validated by default; instead they're merely annotations - information for the application to act upon.
However, many implementations do have validation that can be enabled. Many also support custom formats, though you'd likely need to provide the logic yourself.
An alternative approach is to split the time range into its start and end components and validate those independently. Then all your app has to do is verify that start < end
.