Provides a simple way to validate raw JSON input for safe handling during processing.
npm i json-validator --save
Checkout example.js for more details
let raw = {
a: 'string-value',
b: 0,
c: boolean,
d: undefined,
e: null,
f: []
}
let defaults = {
a: {
required: true, // required (boolean of required) is by default true
type: 'string', // type (string of type) is by default required to be specified
validate: (input) => { return true }, // validate (validate of function) is by default not required
default: 'a' // default (object) is by default required when specifing object data
}
}
validator(raw, defaults, false) // takes raw json, takes default template, and optional boolean if unspecified params in raw remove or include
+ Initial release
- Stable tested release
- Published as official NPM Package