validate-function
v0.0.0
Published
validate
Downloads
1
Readme
validate-function
validate
Install
npm install validate-function
Usage
import {validate, validateAll} from '../src/index'
//Example 1
const rules1 = {
name: {
required: true,
errorMsg:'error'
}
}
validate('name', '', rules1) //=>{errorMsg:'error',key:'name',value:'',required:true}
//Example 2
const rules2 = {
id: {
regexp: regex.IdCard,
errorMsg:'error'
},
name:{
required:true
}
}
validateAll({'id':'31143219781212432x',name:1234}, rules2) //=>[]