valirator

2.2.0 • Public • Published

valirator

Powerful javascript by schema validation tool

npm version Bower version Downloads

GitHub issues Travis status CircleCI status

Dependency status devDependency status

Summary status

Quick start

Several quick start options are available:

  • Download the latest release
  • Clone the repo: git clone https://github.com/massive-angular/valirator.git
  • Install with npm: npm install valirator --save
  • Install with bower: bower install valirator --save

Documentation

For documentation please follow: https://massive-angular.github.io/valirator/

Usage

import { validate } from 'valirator';
 
const validationResult = await validate(schema, obj);

Schema Examples

Simple schema

const schema = {
  Email: {
    required: true,
    minLength: 3,
    maxLength: 50,
  },
  Password: {
    required: true,
    minLength: 3,
    maxLength: 50,
  },
};

Nested schema

const schema = {
  Person: {
    FirstName: {
      required: true,
      maxLength: 50,
    },
    LastName: {
      required: true,
      maxLength: 50,
    },
    Email: {
      required: true,
      format: 'email',
    },
  },
};

Array schema

const schema = {
  Employees: {
    rules: {
      required: true,
      minItems: 5,
    },
    properties: {
      FirstName: {
        required: true,
        maxLength: 50,
      },
      LastName: {
        required: true,
        maxLength: 50,
      },
      Email: {
        required: true,
        format: 'email',
      },
    },
    messages: {
      required: 'Please fill %{property}',
    },
  },
};

Creators

Alexandr Dascal

Slava Matvienco

License

Code released under the MIT license.

Dependencies (0)

    Dev Dependencies (26)

    Package Sidebar

    Install

    npm i valirator

    Weekly Downloads

    50

    Version

    2.2.0

    License

    MIT

    Unpacked Size

    396 kB

    Total Files

    53

    Last publish

    Collaborators

    • massive-angular