Open antoniusostermann opened 4 years ago
This definitely seems possible but I have to think about the right design.
Besides the custom keywords issue, what other features were you looking for?
Is there any chance for this ticket to be finished? Unfortunately, I'm not so familiar with TS and can't help you with PR.
@nordluf planning on getting to this ASAP but unfortunately probably not this week.
The last update on this was quite a long time ago. Did you ever decide to move forward with this?
First of all: Thanks for this small library, it's exactly what I was looking for.
I'm trying to combine this library with AJV, struggling with the right way to use "custom keywords" (https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md) with
ts-json-validator
.ts-json-validator
does not allow any kind of keywords which aren't part of the official JSON Schema specification, so it throws an error for something like this:("Object literal may only specify known properties, and 'forbiddenNames' does not exist in type (...)")
One possible solution could be to allow additional typings via an optional generic and merge those toegether with the already existing ones, so I'd be able to use
createSchema<{ forbiddenNames: string[] }>
which would merge the parameter-type with the given one. As a further improvement,createSchema
could even "inherit" the given type whenever sub-schemas are defined via properties etc.What do you think about this?
Edit: Nevermind, had to switch to https://github.com/bcherny/json-schema-to-typescript due to some additional requirements. Keep up the great work! :-)