typescript-json-validator:使用JSON Schema和AJV为任何TypeScript类型自动生成验证器

时间:2021-05-02 15:58:48
【文件属性】:
文件名称:typescript-json-validator:使用JSON Schema和AJV为任何TypeScript类型自动生成验证器
文件大小:93KB
文件格式:ZIP
更新时间:2021-05-02 15:58:48
TypeScript TypeScript JSON验证程序 使用JSON Schema和AJV为任何TypeScript类型自动生成验证器。 用法 在src/Example.ts定义一个类型,例如: export default interface ExampleType { value : string ; /** * @TJS -format email */ email ?: string ; /** * @default 42 */ answer: number ; } 要生成验证器,请运行: npx typescript-json-validator src/Example.ts ExampleType 这将生成src/Example.validator.ts ,您可以使用: import { readFileSync } from 'fs' ;
【文件预览】:
typescript-json-validator-master
----.gitignore(365B)
----package.json(2KB)
----src()
--------cli.ts(52B)
--------template.ts(5KB)
--------DisjointUnionExample.ts(457B)
--------parseArgs.ts(7KB)
--------loadTsConfig.ts(1KB)
--------__tests__()
--------DisjointUnionExample.validator.ts(5KB)
--------printValidator.ts(2KB)
--------index.ts(1KB)
--------parse.ts(1008B)
--------prettierFile.ts(308B)
--------ComplexExample.ts(352B)
--------normalizeSchema.ts(3KB)
--------usage.ts(506B)
--------Example.ts(158B)
----tsconfig.json(725B)
----README.md(5KB)
----.circleci()
--------config.yml(1KB)
----LICENCE.md(1KB)
----.editorconfig(146B)
----.prettierrc(78B)
----yarn.lock(159KB)

网友评论