node-simple-validator
v2.0.0
Published
A simple validator of data
Downloads
19
Maintainers
Readme
node-simple-validator
A simple data validator
Validators
- CPF
- Number
- Number String (Example: "2500" or 2500)
- String
Installation
# Using npm
npm install --save node-simple-validator
# Using yarn
yarn add node-simple-validator
To validate CPF
const { isCpf } = require('node-simple-validator')
isCpf('CPF')
// if valid, return true
To validate Email
const { isEmail } = require('node-simple-validator')
isEmail('[email protected]') // true
To validate Number
const { isNumber } = require('node-simple-validator')
isNumber(2500) // true
To validate Number String
const { isNumberString } = require('node-simple-validator')
isNumberString("2500") // true
isNumberString(2500) // true
To validate String
const { isString } = require('node-simple-validator')
isString('valid string') // true
isString('', { allowEmpty: true }) // true
To more validations, you can contribute.
Just open pull request with a new folder on src/validators
path, write a validator function and modify index.js
file in validators folder. The validator function must be return only a boolean.
Run tests
npm run test