Skip to content

Commit

Permalink
Improve error messages for validation of missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Dec 2, 2013
1 parent 3cf6023 commit 68f41e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var validateType = (require.modules || {}).validation = module.exports = functio

if (!schemaType) return pass;

if (schemaType === true) return assert(value, 'value');
if (schemaType === true) return assert(value, 'value', value || 'nothing');

if (schemaType === Object) return pass;
if (_.isPlainObject(schemaType)) {
Expand Down Expand Up @@ -114,6 +114,6 @@ var validateType = (require.modules || {}).validation = module.exports = functio
if (schemaType === Number) return assert(_.isNumber(value), 'number');
if (schemaType === Boolean) return assert(_.isBoolean(value), 'boolean');
if (schemaType === Date) return assert(_.isDate(value), 'date');
if (schemaType instanceof RegExp) return assert(schemaType.test(value), 'regex ' + schemaType.toString() + ' to match', value.toString());
if (schemaType instanceof RegExp) return assert(schemaType.test(value || ''), 'regex match on ' + schemaType.toString(), (value || 'nothing').toString());
return assert(value instanceof schemaType, 'instanceof ' + schemaType.toString());
};

0 comments on commit 68f41e9

Please sign in to comment.