src | ||
.env | ||
.gitignore | ||
package.json | ||
pnpm-lock.yaml | ||
README.md | ||
tsconfig.json |
Extollo runtime type validation proof-of-concept
You can read more about this proof-of-concept here:
https://garrettmills.dev/blog/2022/01/14/Runtime-Data-Validation-from-TypeScript-Interfaces/
To run it:
pnpm i
pnpm build
The intermediate files are generated in the exbuild/
directory, and the final compiled output is in the lib/
directory.
Access the Zod schema:
node --experimental-repl-await lib/cli.js shell
powered by Extollo, © 2022 Garrett Mills
Access your application using the "app" global.
(extollo) ➤ Home = require('./lib/app/http/controllers/main/Home.controller').Home
[class Home extends Controller]
(extollo) ➤ home = new Home
Home { request: undefined }
(extollo) ➤ home.getValidator().getZod().shape
{
username: ZodString {
spa: [Function (anonymous)],
superRefine: [Function (anonymous)],
_def: { checks: [Array], typeName: 'ZodString' },
transform: [Function: bound ],
default: [Function: bound ],
_regex: [Function (anonymous)],
nonempty: [Function (anonymous)]
},
password: ZodString {
spa: [Function (anonymous)],
superRefine: [Function (anonymous)],
_def: { checks: [Array], typeName: 'ZodString' },
transform: [Function: bound ],
default: [Function: bound ],
_regex: [Function (anonymous)],
nonempty: [Function (anonymous)]
},
rememberMe: ZodOptional {
spa: [Function (anonymous)],
superRefine: [Function (anonymous)],
_def: { innerType: [ZodBoolean], typeName: 'ZodOptional' },
transform: [Function: bound ],
default: [Function: bound ]
}
}