data-reviser
TypeScript icon, indicating that this package has built-in type declarations

0.0.18 • Public • Published

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

Package Sidebar

Install

npm i data-reviser

Weekly Downloads

1

Version

0.0.18

License

MIT

Unpacked Size

44.3 kB

Total Files

45

Last publish

Collaborators

  • coin_124