Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JTD timestamp validation option - string/date/either #1543

Closed
jrr opened this issue Apr 9, 2021 · 2 comments
Closed

JTD timestamp validation option - string/date/either #1543

jrr opened this issue Apr 9, 2021 · 2 comments

Comments

@jrr
Copy link
Contributor

jrr commented Apr 9, 2021

What version of Ajv you are you using?
8.0.5

What problem do you want to solve?
The JTD timestamp type currently accepts both Date objects and properly-formatted strings. I'd like to be able to restrict this to just Dates.

What do you think is the correct solution to problem?
Perhaps a new option?

Something like

type JtdTimestampOption = "dateObject" | "isoString" | "both";

// then add to JTDOptions e.g.:
timestampAccepts?: JtdTimestampOption

With a default of "both".

Will you be able to implement it?

I think so.


Related: ajv-validator/ajv-keywords#166

@jrr jrr added the enhancement label Apr 9, 2021
@epoberezkin
Copy link
Member

let's make a bit shorter/simpler:

timestamp?: "date" | "string" // with missing/undefined property to allow both

@epoberezkin
Copy link
Member

it should be defined in core.ts, and then all subclasses other than jtd.ts could override it as never

# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

2 participants