Skip to content
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

Request: Add relative validation support and keywords for date,date-time #41

Open
tars400 opened this issue Sep 7, 2021 · 4 comments
Open

Comments

@tars400
Copy link

tars400 commented Sep 7, 2021

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

@Relequestual
Copy link
Member

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.

@Relequestual Relequestual transferred this issue from json-schema-org/json-schema-spec Sep 7, 2021
@karenetheridge
Copy link
Member

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?

@sandrina-p
Copy link

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 :/

@jdesrosiers
Copy link
Member

Here are a couple implementation specific guides you might find useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants