Closed masx200 closed 2 years ago
Hi, what kind of validator you mean? To validate what? Schemas? Data? Validate by some rules or just by TS types?
const validator=new Validator<{foo:string,bar:number}>()
validator.validate(JSON.parse("something"))
validator.validate({foo:"something",bar:999})
There is no such validator inside this project. This project is clear Reflection system.
Validator might be some other package using this package to implement the validation.
But such validation is quite simple and you can use built in Type.isAssignableTo(someOtherType)
and runtime type construction via getType(some runtime value)
.
Check this https://stackblitz.com/edit/tst-reflect-validation?file=index.ts.
But those are quite experimental features.
But maybe you can use https://github.com/joeferner/tst-reflect-json-schema-generator and then u can use existing schema validators or maybe you'll find useful this https://github.com/ciricc/tst-defaults.
is there a typescript runtime validator?