form-lazy
v1.0.0
Published
Simple form data validation
Downloads
3
Readme
FORML (Form Lazy)
Simple form data validation
Introduction
Installation
# NPM
$ npm install forml --save
# Yarn
$ yarn add forml
Basic Usage
import Forml from 'forml'
const input = {
firstname: 'John',
lastname: 'Doe',
email: '[email protected]'
}
const rules {
firstname: {
required: true,
length: 5,
custom: (input, error) => {
if (input === 'John') {
error.message = 'John is banned from this system'
return error;
}
}
},
lastname: {
required: true,
legnth: 3,
},
email: {
email: true
}
}
const hasErrors = Forml.validate(input, rules);
if (hasErrors.length) {
console.error('We have some errors to resolve ', hasErrors);
}
// Everything is fine ...