validata
A flexible input validator written in typescript
Installation
npm install --save @ajkachnic/validata
Usage
You can use validata in a few different ways
import { isEmail } from 'validata';
console.log(isEmail('name@website.com'));
import validate from 'validata';
let result = validate('name@website.com', {
isEmail: true
});
console.log(result);
var validata = require('validata');
console.log(validate.isEmail('name@website.com'));
var validata = require('validata').default;
var result = validate('name@website.com', {
isEmail: true
});
console.log(result);
API
The following functions are exported from validata
isEmail(value) - Returns if an email is valid
isUrl(value) - Returns if a URL is valid
isHex(value) - Returns if a hex code is valid
isIp(value) - Returns if an IP Address (V4) is valid
isEmpty(value) - Returns if a string is empty
fitsMax(value, max) - Returns if a strings length is less than or equal to the max parameter
fitsMin(value, min) - Returns if a strings length is greater than or equal to the min parameter
The config object has these options. You can pass multiple parameters
Note: The function returns false once one of the options is false
isEmail
isUrl
isHex
isIp
isEmpty
max
min