json-type-check

0.2.1 • Public • Published

json-type-check

A typechecker for JSON

Build Status Code Climate Code Coverage
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) // []

Readme

Keywords

none

Package Sidebar

Install

npm i json-type-check

Weekly Downloads

1

Version

0.2.1

License

ISC

Last publish

Collaborators

  • ccetc
  • mahaplatform
  • mochini