README
Easy Form Validation
const { Validator } = require('valid-form');
let validate = new Validator();
const form = {
email: 'johnDoe@gmail.com',
fullName: 'John Doe',
username: 'johnDoe123',
password: 'Asdfasdaf123',
repPassword: 'Asdfasdaf123',
};
validate.formValidation(form, (validated) => {
console.log(validated);
});
Installation
npm install form-validate
Usage
Pass form object to --> validate.formValidation(form);
import { Validator } from 'valid-form';
let validate = new Validator();
const validated = await validate.formValidation(form);
console.log(validated);
or
const { Validator } = require('valid-form');
const validate = new Validator();
validate.formValidation(form), (data) => {
consle.log(data);
});
Custom validation
Pass custom pattern (regex) or action function pattern must be in regex format with action pass error message
const { Validator } = require('../dist');
let validate = new Validator({
username: {
pattern: '^[a-zA-Z0-9]([._](?![._])|[a-zA-Z0-9]){3,18}[a-zA-Z0-9]