You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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! :-)
The text was updated successfully, but these errors were encountered: