You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

# 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/](https://garrettmills.dev/blog/2022/01/14/Runtime-Data-Validation-from-TypeScript-Interfaces/)
To run it:
```shell
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:
```txt
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 ]
}
}
```