json-type-check
v0.2.1
Published
A typechecker for JSON
Downloads
3
Readme
json-type-check
A typechecker for JSON
import Jst from 'json-type-check'
const value = {
requiredString: 'foo'
}
const schema = Jst.shape({
requiredString: [
Jst.string,
Jst.required
],
optionalInteger: Jst.integer,
optionalDate: Jst.date,
optionalEnum: Jst.oneOf([
Jst.integer,
Jst.string
])
})
const check = new Jst(value, schema)
console.log(check.valid) // true
console.log(check.errors) // []