validator-schema
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

validator-schema

Install (already includes TypeScript definition file).

npm i -S validator-schema

Schema validation example

import validator, { Schema } from 'validator-schema';

const schema: Schema = {
  name: {
    type: 'string',
    test: /goku/i,
    fn: v => v && v.length > 0,
  },
};

const validate = validator(schema);

const user = {
  name: 'Goku',
};

validate(user); // { valid: true, errors: [] }

See tests for more examples.

Readme

Keywords

none

Package Sidebar

Install

npm i validator-schema

Weekly Downloads

2

Version

0.1.2

License

MIT

Last publish

Collaborators

  • brunolm