Consolidate Standard Schema implementations #1239
Not-Jayden
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know there's currently 2 implementations of Standard Schema floating around (both in the example directory of this repo and on the TypeMap Validator class).
To me the
Validator
class seems like it could potentially just extend/implement the TypeBoxTypeCheck
class, as it's effectively just returning the same methods, sansSchema
/Encode
/Decode
/ and addingParse
.I guess my main question is: Can
TypeCheck
extend/implement Standard Schema so you don't need to add TypeMap as another dependency? Particularly seeing as it can all be implemented with the code inside the TypeBox package, and perhaps the StandardSchemaProps can be moved into this repo and imported from TypeMap package.I think the only thing that would probably need to differ between the two packages is the vendor name, for backwards compatibility reasons, and probably use something like
@sinclair/typebox/compiler
for the vendor name inTypeCheck
.Putting that to the side, I'd probably want to at least expose the
Schema()
method on the TypeMapValidator
class, as I'm working on adding TypeMap support for it in the Standard JSON package, and doingschema.__check.Schema()
on the Validator instance is a hack. I'd also look to add support for the TypeBox TypeCheck instance as well though if the above change is made^Beta Was this translation helpful? Give feedback.
All reactions