README
apemanschema
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.