Request: Add relative validation support and keywords for date,date-time
We need to support relative validation on json-schema for date format.
Is there any existing support where relative validations are supported for 'date' or 'date-time' formats ?, as the current schema supports only absolute validation with formatMinimum and formatMaximum.
Something like below:
{
type: 'string',
format: 'date',
formatMinimum: '2019-08-16',
formatMaximum: '2022-08-16',
relativeMinimumDate: -50, // -ve for current day - number of days
relativeMaximumDate: 20, // +ve for current day + number of days
// considering the above example, input date should be between last 50 days to coming 20 days.
}
relative minimum and relative maximum format would validate on date relatively example: last 1 year, last 20 days, last 12 months etc
Hi @tars400. We don't have any keywords which dynamically use content from the instance like you're proposing. We do have several proposals for accessing instance data dynamically.
I can't imagine we will get this into the spec any time soon.
You CAN now write your own extension (vocabulary), but you would be dependent on providing implementations for it to work.
the current schema supports only absolute validation with formatMinimum and formatMaximum
These aren't keywords in the official JSON Schema specification. Perhaps your particular implementation added them?
You CAN now write your own extension (vocabulary), but you would be dependent on providing implementations for it to work.
@Relequestual could you point me to the best guide explaining how to write our own extensions? I found this page but by itself doesn't point to any guide :/
Here are a couple implementation specific guides you might find useful.
- https://docs.json-everything.net/schema/vocabs/
- https://github.com/hyperjump-io/json-schema#meta-schemas-keywords-vocabularies-and-dialects-experimental