Skip to content

Commit

Permalink
do Array check before typeof, #212
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Feb 23, 2019
1 parent ddd8a58 commit 89500ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ define( require => {
if ( typeof valueType === 'string' ) { // primitive type
assert( typeof value === valueType, `value should have typeof ${valueType}, value=${value}` );
}
else if ( typeof valueType === 'function' ) { // constructor
assert( value instanceof valueType, `value should be instanceof ${valueType.name}, value=${value}` );
}
else if ( valueType === Array ) {
assert( Array.isArray( value ), `value should have been an array, value=${value}` );
}
else if ( typeof valueType === 'function' ) { // constructor
assert( value instanceof valueType, `value should be instanceof ${valueType.name}, value=${value}` );
}
}
validator.validValues && assert( validator.validValues.indexOf( value ) >= 0, `value not in validValues: ${value}` );
validator.isValidValue && assert( validator.isValidValue( value ), `value failed isValidValue: ${value}` );
Expand Down

0 comments on commit 89500ae

Please sign in to comment.