cmn-util
v0.0.2
Published
It contains utilities for Common node js validators and some more utilities
Downloads
1
Maintainers
Readme
Common utilities for node and express JS
- validators
- empty validator
- Is email check
- is phone number for Indian numbers
- ip checker
Empty validator
It can validate array and objects and empty string and also added null and undefined.
const { validator } = require('cmn-util');
let check;
console.log(validator.isEmpty(check)); // true
check = undefined;
console.log(validator.isEmpty(check)); // true
check = null;
console.log(validator.isEmpty(check)); // true
check = '';
console.log(validator.isEmpty(check)); // true
check = ' ';
console.log(validator.isEmpty(check)); // true
check = {};
console.log(validator.isEmpty(check)); // true
check = [];
console.log(validator.isEmpty(check)); // true
Email validator
It can check is email is valid or not.
const { validator } = require('cmn-util');
let check = '[email protected]';
console.log(validator.isEmail(check)); // true
check = 'sample.com';
console.log(validator.isEmail(check)); // false
Indian phone number validate
It can check the phone number is valid or not.
const { validator } = require('cmn-util');
let check = 9876543210;
console.log(validator.isPhone(check)); // true
check = 137342998374;
console.log(validator.isPhone(check)); // false
IP Address validator
It validate is valid IP address or not for only ipv4.
const { validator } = require('cmn-util');
let check = '127.0.0.1';
console.log(validator.isIP(check)); // true
check = '127.0.512.299';
console.log(validator.isIP(check)); // false