A TypeScript custom transformer to obtain json schema for fastest-validator from TypeScript interface
$ npm install ts-transformer-json-schema --save
TypeScript >= 2.4.1 TTypeScript
How to use directly with fastest-validator
How to use with Moleculer
There is moleculer template that comes with this transformer and configure compiler to use it: https://github.com/ipetrovic11/moleculer-template-typescript
How to use the custom transformer
Unfortunately, TypeScript itself does not currently provide any easy way to use custom transformers (See https://github.com/Microsoft/TypeScript/issues/14419).
See ttypescript's README for how to use this with module bundlers such as webpack or Rollup.
What can be transformed
Currently transformer can handle:
Intersections and Unions
Emails - Predefined - IEmail
Dates - Predefined - IDate
UUID - Predefined - IUUID
Forbidden - Predefined - IForbidden
Take a look at tests for all possibilities. All cases from fastest-validator should be covered, if not please report the issue.