Skip to content

Commit

Permalink
Move typeof check earlier to also fix enums with undefined data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Scott committed Dec 7, 2015
1 parent 83cffaa commit 2b60d74
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions source/basic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ValidatorContext.prototype.validateBasic = function validateBasic(data, schema, dataPointerPath) {
if (typeof data === "undefined") {
return null;
}
var error;
if (error = this.validateType(data, schema, dataPointerPath)) {
return error.prefixWith(null, "type");
Expand All @@ -14,9 +17,6 @@ ValidatorContext.prototype.validateType = function validateType(data, schema) {
return null;
}
var dataType = typeof data;
if (dataType === "undefined") {
return null;
}
if (data === null) {
dataType = "null";
} else if (Array.isArray(data)) {
Expand Down
20 changes: 10 additions & 10 deletions test/all_concat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tv4.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ function recursiveCompare(A, B) {
}

ValidatorContext.prototype.validateBasic = function validateBasic(data, schema, dataPointerPath) {
if (typeof data === "undefined") {
return null;
}
var error;
if (error = this.validateType(data, schema, dataPointerPath)) {
return error.prefixWith(null, "type");
Expand All @@ -732,9 +735,6 @@ ValidatorContext.prototype.validateType = function validateType(data, schema) {
return null;
}
var dataType = typeof data;
if (dataType === "undefined") {
return null;
}
if (data === null) {
dataType = "null";
} else if (Array.isArray(data)) {
Expand Down
Loading

0 comments on commit 2b60d74

Please sign in to comment.