apemanschema

7.2.0 • Public • Published

apemanschema

Build Status Code Climate Code Coverage npm Version JS Standard

JSON schema validator for apeman.

Installation

$ npm install apemanschema --save

Usage

Create a directory with name "schemas" and put schema files like "User.schema.json" there.

schemas/user.json

{
  "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"
  ]
}

schemas/index.js

'use strict'
 
const apemanschema = require('apemanschema')
 
// Exports schemas as module.
module.exports = apemanschema(__dirname, {
  // Options
})
 

Then,

'use strict'
 
// Require defined schemas
const schemas = require('./schemas/index.js')
 
let error = schemas('user').validate({
  name: 'foo'
})
 
console.log(error)
 

License

This software is released under the MIT License.

Links

Readme

Keywords

Package Sidebar

Install

npm i apemanschema

Weekly Downloads

9

Version

7.2.0

License

MIT

Last publish

Collaborators

  • okunishinishi