Skip to content

Extending a Validator for new types #1090

Answered by Julian
crburke asked this question in Q&A
Discussion options

You must be logged in to vote

It's incorrect in the sense that that isn't allowed in Draft 2020 -- the set of types are fixed and not extendable, so you're getting an error telling you "your schema is invalid" (which it is -- the metaschema also constrains the types to a fixed list which is what you're seeing there).

You could of course create your own dialect exactly like 2020 but with this restriction removed, for example by calling jsonschema.validators.create with some new metaschema that's the 2020 one but just with that condition removed and with otherwise all the same logic.

Better is to not do this though and to invent your own keyword instead, so that your new dialect is not invalid under 2020 and instead ext…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Julian
Comment options

Answer selected by crburke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants