Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 654 Bytes

Readme.md

File metadata and controls

43 lines (27 loc) · 654 Bytes

schema-validate

Validator to validate a model against a json schema.

Installation

Install with component(1):

$ component install mikanda/schema-validate

Usage

var model = require('model')
  , schemaValidate = require('schema-validate');

var User = model('user')
  .use(schemaValidate())

  // define your attributes using json-schema

  .attr('name', {
    type: 'string',
    required: true
  })
  ...
  ;
var user = new User({ ... });
user.validate();

// console.log(user.errors);

API

SchemaValidate()

Initializes a new validator.

License

MIT