Commit 4914da49 authored by Jaap Karan Singh's avatar Jaap Karan Singh

Initial commit

parents
node_modules
npm-debug.log
\ No newline at end of file
/* jshint node:true */
'use strict';
console.info('[DANGER] Overriding jsonschema module manually. It will be replaced once the module is updated. Pull request submitted - https://github.com/tdegrunt/jsonschema/pull/62');
module.exports = require(__dirname + '/src');
\ No newline at end of file
{
"name": "jsonschema-validator",
"version": "0.0.1",
"dependencies": {
"jsonschema": {
"version": "0.4.0",
"from": "jsonschema@"
},
"lodash": {
"version": "2.4.1",
"from": "lodash@"
},
"mongoskin": {
"version": "0.6.1",
"from": "mongoskin@",
"dependencies": {
"mongodb": {
"version": "1.3.19",
"from": "mongodb@1.3.19",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-1.3.19.tgz",
"dependencies": {
"bson": {
"version": "0.2.2",
"from": "bson@0.2.2",
"resolved": "https://registry.npmjs.org/bson/-/bson-0.2.2.tgz"
},
"kerberos": {
"version": "0.0.3",
"from": "kerberos@0.0.3",
"resolved": "https://registry.npmjs.org/kerberos/-/kerberos-0.0.3.tgz"
}
}
}
}
}
}
}
{
"name": "jsonschema-validator",
"version": "0.0.1",
"description": "jsonschema validator with custom types and attributes",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jaap Karan Singh <jksdua@gmail.com>",
"dependencies": {
"jsonschema": "~0.4.0",
"mongoskin": "~0.6.1",
"lodash": "~2.4.1"
}
}
JSON Schema Validator
=====================
jsonschema validator with custom types and attributes
Changelog
---------
### v0.0.1
- Initial commit
\ No newline at end of file
/* jshint node:true */
'use strict';
var _ = require('lodash');
var jsonschema = require('jsonschema');
var customTypes = require(__dirname + '/types');
var BasicValidator = jsonschema.Validator;
var customAttributes = require(__dirname + '/attributes');
function Validator() {
BasicValidator.apply(this, arguments);
_.extend(this.attributes, customAttributes);
}
var proto = Validator.prototype = Object.create(BasicValidator.prototype);
proto.types = Object.create(proto.types);
_.extend(proto.types, customTypes);
module.exports = Validator;
\ No newline at end of file
/* jshint node:true */
'use strict';
exports.validate = function customValidate(instance, schema, opt, ctx) {
if (instance || schema.required) {
return schema.validate(instance, schema, opt, ctx);
}
};
exports.conditionalEnum = function conditionalEnum(instance, schema, options, ctx) {
var res;
if (instance) {
schema.enum = schema.conditionalEnum;
res = this.attributes.enum(instance, schema, options, ctx);
delete schema.enum/* = void 0 */;
}
return res;
};
\ No newline at end of file
/* jshint node:true */
'use strict';
var jsonschema = require('jsonschema');
exports.ValidationError = jsonschema.ValidationError;
exports.SchemaError = jsonschema.SchemaError;
exports.Validator = require(__dirname + '/Class.Validator');
exports.validator = new exports.Validator();
exports.custom = {
attributes: require(__dirname + '/attributes'),
types: require(__dirname + '/types')
};
\ No newline at end of file
/* jshint node:true */
'use strict';
var _ = require('lodash');
var mongo = require('mongoskin');
exports.error = function testError(er) {
return (er instanceof Error);
};
exports.regexp = function testRegexp(re) {
return (re instanceof RegExp);
};
exports.function = function testFunction(fn) {
return (fn instanceof Function);
};
// works for both string representations and objectid instances
exports.objectId = function testObjectId(id) {
try {
new mongo.ObjectID(id.toString());
return true;
} catch(e) {
return false;
}
};
exports.plainObject = function testPlainObject(ob) {
return _.isPlainObject(ob);
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment