aschema

3.1.0 • Public • Published

aschema

Build Status npm Version JS Standard

JSON schema validator

Installation

$ npm install aschema --save

Usage

'use strict'
 
const aschema = require('aschema')
 
// Define a schema object
const userSchema = aschema({
  title: 'User',
  description: 'A user',
  type: 'object',
  properties: {
    id: {
      description: 'The unique identifier for a account',
      type: 'integer'
    },
    accountName: {
      description: 'Name of the account',
      type: 'string'
    }
  },
  required: [
    'id',
    'name'
  ]
})
 
// Execute validation
let error = userSchema.validate({
  name: 'foo'
})
 
if (error) {
  console.error(error)
} else {
  console.log('no error!')
}
 

License

This software is released under the MIT License.

Links

Readme

Keywords

Package Sidebar

Install

npm i aschema

Weekly Downloads

14

Version

3.1.0

License

MIT

Unpacked Size

26.8 kB

Total Files

31

Last publish

Collaborators

  • okunishinishi