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 b8bc240
Showing 1 changed file with 3 additions and 3 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

0 comments on commit b8bc240

Please sign in to comment.