Validator adapter json-schema for node-document ODM for Node.js.
$ npm install node-document-validator-jsonschema
Basic:
var Validator = require('node-document-validator-jsonschema');
var validator = new Validator();
var data = {
foo: "foo",
bar: 123,
baz: undefined
};
var schema = {
foo: {
type: "string",
minLength: 4
},
bar: {
type: "number"
},
baz: {
required: true
}
};
validator.validate(data, schema, function(err, errors, valid) {
console.log("Valid: %s \nErrors:\n", valid, errors);
});
For details; see node-document.
Local tests:
$ make test
Released under the MIT license.
Copyright (c) Jonas Grimfelt