@dynejs/validator
v0.0.2
Published
A simple validation library with a few basic rules.
Downloads
3
Readme
DyneJS / Validator
A simple validation library with a few basic rules.
Sample usage
First parameters is data what needs to be validated. In the second paramter we define the rules.
Rules separated with |
sign. Parameters can be passed after :
sign.
Example rule: required|min:2|max:10
const { validate } = require('@dynejs/validator')
validate(data, {
'title': 'required',
'field': 'required|list:one,two',
// You can use asterisk to check arrays
'anArray.*.ids.*.value': 'required'
})
Rules
- required
- list
- number
- min
- max
- url
- hex
- boolean
- notNull
License
MIT license.