Skip to content

Commit

Permalink
v6.0.2: fixes #125
Browse files Browse the repository at this point in the history
  • Loading branch information
zaggino committed Jul 29, 2024
1 parent 1b071e0 commit 5a6a5dc
Show file tree
Hide file tree
Showing 9 changed files with 6,454 additions and 4,784 deletions.
2 changes: 1 addition & 1 deletion dist/ZSchema-browser-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ZSchema-browser-min.js.map

Large diffs are not rendered by default.

6,410 changes: 4,012 additions & 2,398 deletions dist/ZSchema-browser-test.js

Large diffs are not rendered by default.

2,712 changes: 1,014 additions & 1,698 deletions dist/ZSchema-browser.js

Large diffs are not rendered by default.

2,069 changes: 1,384 additions & 685 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "z-schema",
"version": "6.0.1",
"version": "6.0.2",
"engines": {
"node": ">=16.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions src/JsonValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ var JsonValidators = {
if (shouldSkipValidate(this.validateOptions, ["INVALID_FORMAT"])) {
return;
}
if (report.hasError("INVALID_TYPE", [schema.type, Utils.whatIs(json)])) {
return;
}
if (formatValidatorFn.length === 2) {
// async - need to clone the path here, because it will change by the time async function reports back
var pathBeforeAsync = Utils.clone(report.path);
Expand Down
37 changes: 37 additions & 0 deletions test/ZSchemaTestSuite/Issue125.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";

var REF_NAME = "int.json";

module.exports = {
description: "Issue #125 - Why process format if type validation fails",
setup: function (validator, Class) {
Class.registerFormat("test", function (item) {
return typeof item === 'string';
});
},
tests: [
{
description: "should fail with one error",
schema: {
type: "object",
properties: {
callbacks: {
type: "array",
items: {
type: "string",
format: "test",
},
},
},
},
data: {
callbacks: [true],
},
valid: false,
after: function (err, valid, data, validator) {
expect(err.length).toBe(1);
expect(err[0].code).toBe("INVALID_TYPE");
}
}
]
};
1 change: 1 addition & 0 deletions test/spec/ZSchemaTestSuiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var testSuiteFiles = [
require("../ZSchemaTestSuite/Issue106.js"),
require("../ZSchemaTestSuite/Issue107.js"),
require("../ZSchemaTestSuite/Issue121.js"),
require("../ZSchemaTestSuite/Issue125.js"),
require("../ZSchemaTestSuite/Issue126.js"),
require("../ZSchemaTestSuite/Issue130.js"),
require("../ZSchemaTestSuite/Issue131.js"),
Expand Down

0 comments on commit 5a6a5dc

Please sign in to comment.