Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var environment = jsv.createEnvironment("json-schema-draft-03");
/**
* Patch JSV so it always clones instances before validation
* so filters don't affect the original object.
*/
environment.createInstance = function(data, uri) {
data = jsv.clone(data, true);
return jsv.Environment.prototype.createInstance.call(this, data, uri);
};
var schemaSchema = environment.getDefaultSchema()
, oldValidator = schemaSchema.getAttribute("validator");
schemaSchemaJson = jsv.inherits(schemaSchema, {
/**
* Patch the number type validator to not report NaN's as numbers.
*/
"properties": {
"type": {
"typeValidators": {
"number": function(instance, report) {
return instance.getType() === "number" && !isNaN(instance.getValue());
}
}
}
},
/**
* Patch it to run filters before running validators.
*/