Skip to content

Commit

Permalink
Merge pull request #254 from antialias/patch-1
Browse files Browse the repository at this point in the history
passing null instead of undefined when no error present
  • Loading branch information
zaggino committed Apr 24, 2020
2 parents b3de844 + 5a1058f commit 5b6a6e3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Report.prototype.processAsyncTasks = function (timeout, callback) {
function finish() {
process.nextTick(function () {
var valid = self.errors.length === 0,
err = valid ? undefined : self.errors;
err = valid ? null : self.errors;
callback(err, valid);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ ZSchema.prototype.getLastError = function () {
return e;
};
ZSchema.prototype.getLastErrors = function () {
return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : undefined;
return this.lastReport && this.lastReport.errors.length > 0 ? this.lastReport.errors : null;
};
ZSchema.prototype.getMissingReferences = function (arr) {
arr = arr || this.lastReport.errors;
Expand Down
2 changes: 1 addition & 1 deletion test/spec/AutomaticSchemaLoadingSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("Automatic schema loading", function () {

validateWithAutomaticDownloads(validator, data, schema, function (err, valid) {
expect(valid).toBe(true);
expect(err).toBe(undefined);
expect(err).toBe(null);
done();
});

Expand Down
4 changes: 2 additions & 2 deletions test/spec/ZSchemaTestSuiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe("ZSchemaTestSuite", function () {
}

if (test.valid === true) {
expect(err).toBe(undefined, "errors are not undefined when test is valid");
expect(err).toBe(null, "errors are not undefined when test is valid");
}

if (after) {
Expand All @@ -186,7 +186,7 @@ describe("ZSchemaTestSuite", function () {
expect(typeof valid).toBe("boolean", "returned response is not a boolean");
expect(valid).toBe(test.valid, "test result doesn't match expected test result");
if (test.valid === true) {
expect(err).toBe(undefined, "errors are not undefined when test is valid");
expect(err).toBe(null, "errors are not undefined when test is valid");
}
if (after) {
after(err, valid, data);
Expand Down

0 comments on commit 5b6a6e3

Please sign in to comment.