README
validator-with-rules
validator-with-rules is a nodejs library for validating form.
Installation
Use the package manager to install validator-with-rules.
npm install foobar
Usage
import { validate } from "validator-with-rules";
const data = {
email: "iqbal.pk@acodez.co.in",
password: "********",
};
const rules = {
email: {
notNull: true,
regex: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
},
password: {
notNull: true,
minLength: 4,
maxLength: 10,
},
image: {
notNull: false,
maxSize: 500,
},
};
let err = validate(data, rules);
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.