diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js')
-rw-r--r-- | deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js b/deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js index 97cbbf6fa3..4b6108800a 100644 --- a/deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js +++ b/deps/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/json-schema/lib/validate.js @@ -13,10 +13,23 @@ empty list will be returned. A validation error will have two properties: "property" which indicates which property had the error "message" which indicates what the error was */ -({define:typeof define!="undefined"?define:function(deps, factory){module.exports = factory();}}). -define([], function(){ -var exports = validate; -// setup primitive classes to be JSON Schema types +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], function () { + return factory(); + }); + } else if (typeof module === 'object' && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals + root.jsonSchema = factory(); + } +}(this, function () {// setup primitive classes to be JSON Schema types +var exports = validate exports.Integer = {type:"integer"}; var primitiveConstructors = { String: String, @@ -194,8 +207,8 @@ var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*O if(typeof instance != 'object' || instance instanceof Array){ errors.push({property:path,message:"an object is required"}); } - - for(var i in objTypeDef){ + + for(var i in objTypeDef){ if(objTypeDef.hasOwnProperty(i)){ var value = instance[i]; // skip _not_ specified properties @@ -257,4 +270,4 @@ exports.mustBeValid = function(result){ } return exports; -}); +})); |