/data-reviser

Validate data type & data structure. Translate data type automatically.

Primary LanguageTypeScriptMIT LicenseMIT

Build Status npm version

Features

  1. Validate data type and data structure.
  2. Translate data type.

Build Setup

yarn install    # Dependecies
yarn run dev    # Dev
yarn run build  # Build
yarn run test   # Test

Installation

npm install data-reviser
# or
yarn add data-reviser

Usage

Basic Usage

import { Reviser, TypeInt32, ToInt32 } from 'data-reviser';

class M extends Reviser {
  @ToInt32
  @TypeInt32()
  num = 1;
};

const m = new M();
const message = m.set({ num: '123'});

console.log(message);  // { num: { type: string, message: string }}
console.log(m.get());  // { num: 123 }

Inherit

class N extends M {
  @ToInt32
  str = '';
};

const n = new N();
const message = m.set({ str: 123 });

console.log(message);  // null
console.log(m.get());  // { num: 1, str: '123'}

More example see test case.

API documentation

api

For contributors

TODO

Licence

MIT