schemasafe icon indicating copy to clipboard operation
schemasafe copied to clipboard

Code generation that deduplicates validation logic

Open ggoodman opened this issue 3 years ago • 0 comments

Use-case

Imagine you're building validator codecs for a set of inter-related schemas that define $refs on each other. The (awesome) code generation results in these being treated as totally isolated IIFE-enclosed validators. These validators duplicate the validation logic of all referenced schemas.

Request

It would be really interesting to have a facility whereby a set of inter-related schemas could be compiled as a unit and thereby produced smaller validation logic by referencing each other appropriately. I suspect that this would require major changes to how errors are collected as we would now have N validator functions instead of 1 on which errors may be added.

Anyway, schemasafe is a fantastic bit of work. Really appreciate the rigour, speed and comprehensiveness. I'm using it with https://github.com/ggoodman/json-schema-to-dts to build codegen typed validation codecs.

ggoodman avatar Oct 29 '20 21:10 ggoodman