validazz
![Coverage Status](https://img.shields.io/codecov/c/github//master.svg?style=flat-square)
Magical, Flexible and Extendible Javascript Validation
Install
npm:
npm i validazz
Yarn:
yarn add validazz
Usage
import Validator, { rules } from 'validazz'
const mySuperCoolValidator = Validator.factory()
mySuperCoolValidator.addRule(rules.isRequired)
mySuperCoolValidator.addRules([rules.minLength(2), rules.maxLength(8)])
mySuperCoolValidator.addRule(rules.isString)
const customRule = {
runWithValue: value => {
if (value !== '🤪') return false
return true
},
message: 'Houston, we got a problem',
}
mySuperCoolValidator.addRule(customRule)
const { success, failed } = mySuperCoolValidator.runWithValue('hello')
if (success) {
console.log('Wow, this was validated just like that')
} else {
const { message } = failed
console.log(`Okay so here's the error message: ${failed}`)
}
API
Table of Contents
sayHello
This function says hello.
Parameters
name
string Some name to say hello for.
Returns string The hello.
License
MIT © Jesse Onolememen