First thing that you need to do is install the package on your project using this command on your terminal:
npm i simple-validator-node
After that you can use the Validator class to validate your codes:
import Validator from 'simple-validator-node';
const validator = new Validator();
const name = 'jack';
validator.isEmpty(name); //false
Verify if string is empty.
validator.isEmpty(value);
Verify if string is greater than a max length setted by you.
validator.isGreaterThanMaxLength(value, maxLength)
Verify if string is shorter than a min length setted by you.
validator.isShorterThanMinLength(value, minLength);
Verify if string is a date that is write as dd/mm/yy, dd-mm-yy, or dd.mm.yy
validator.isDate(date);
Verify if string has special char
validator.hasEspecialChar(value);
Verify if string is a valid email
validator.isEmail(value);
Verify if string just have numbers
validator.isNumber(value);
Verify if number is an integer
validator.isInt(number);
Verify if a number is greater than a value that you set
validator.isGreater(number, valueToCompare);
Verify if a number is shorter than a value that you set
validator.isShorter(number, valueToCompare);