transform-of-type
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

transform of type

Movition

validate or fatory a type is not a easy thing.

Installation

  • npm install
npm install --save-dev transform-of-type

Usage

import { schemaOf, factoryOf, validatorOf } from "transform-of-type";
 
interface A {
  a: string;
  b: number;
}
 
const schemaString = schemaOf<A>(); // will generate a json-schema string of interface A;
 
factoryOf<A>().then(factory => {
  console.log(factory()); // will generate an object instance of A;
});
 
validatorOf<A>().then(validate => {
  console.log(validate({ a: 1 })); // return false (a is not instance of A);
});

Readme

Keywords

none

Package Sidebar

Install

npm i transform-of-type

Weekly Downloads

4

Version

0.0.1

License

ISC

Unpacked Size

18.3 kB

Total Files

10

Last publish

Collaborators

  • yonghao.wang