Socket
Socket
Sign inDemoInstall

jsonschema

Package Overview
Dependencies
3
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

23

lib/validator.js

@@ -160,15 +160,24 @@ 'use strict';

var i, len;
var invalid;
var errors = [];
for (i = 0, len = schema.type.length; i < len; i++) {
if (typeof schema.type[i] === 'string') {
invalid = this.validateSchema(instance, {'type': schema.type[i]}, {'addError': false});
this.validateSchema(instance, {'type': schema.type[i]});
} else {
invalid = this.validateSchema(instance, schema.type[i], {'addError': false});
this.validateSchema(instance, schema.type[i]);
}
if (!helpers.isDefined(invalid)) {
break;
if (this.errors.length === 0) {
// early exit one element of the union passes the test
return;
} else {
// reset
errors = errors.concat(this.errors);
this.errors = [];
}
}
if (helpers.isDefined(invalid)) {
this.addError("not any of union type");
this.errors = errors;
if (this.errors.length !== 0) {
this.addError("not any of union type");
}

@@ -175,0 +184,0 @@ };

{
"author": "Tom de Grunt <tom@degrunt.nl>",
"name": "jsonschema",
"version": "0.1.0",
"version": "0.1.1",
"dependencies": {

@@ -6,0 +6,0 @@ "mocha": "~1.3.0",

@@ -148,3 +148,17 @@ 'use strict';

it('should validate for objectid and ignore title and description', function () {
var schema = {
"type": "object",
"properties": {
"wildcards": {
"type": "array",
"items": {"type": [{"$ref": "MongoDb#ObjectId", "title": "test", "description": "test"}, {"type": "string", "pattern": "^\\*$"}]}
}
}
};
var validator = new Validator();
validator.validate({'wildcards': [{"id": "1234", "_bsontype": "test"}, '*']}, schema).should.be.empty;
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc