You just write
const personType: Type = typeof(Person);
const personType = { name: "Person", fields: [ { name: "lastName", type: "string" }, { name: "firstName", type: "string" }, ], }
If you would implement validation by hand, you'd come up with absolutely conceptually identical code. Look at any validation libraries out there.
The only difference is: you specify types with nice TypeScript language, not with some made-up abomination DSL.
If it's the way you've shown it'd be great!
You just write
This code gets compiled into There's no runtime. It's just an object which describes layout of some time.If you would implement validation by hand, you'd come up with absolutely conceptually identical code. Look at any validation libraries out there.
The only difference is: you specify types with nice TypeScript language, not with some made-up abomination DSL.