valirator
v2.2.0
Published
Powerful javascript by schema validation tool
Downloads
151
Maintainers
Readme
valirator
Powerful javascript by schema validation tool
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.