Skip to content

Commit

Permalink
supply default message for UserSchema.path("some.path").validate(vali…
Browse files Browse the repository at this point in the history
…dator);
  • Loading branch information
ManInTheBox committed Feb 28, 2012
1 parent aae494b commit 2f18ef5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/schematype.js
Expand Up @@ -361,6 +361,11 @@ SchemaType._isRef = function (self, value, init) {

function ValidatorError (path, type, message) {
message = message || errorMessages[type];

if ('undefined' === typeof message) { // if still don't have message
message = 'Validator failed for path ' + path;
}

MongooseError.call(this, normalizeMessage(path, message));
Error.captureStackTrace(this, arguments.callee);
this.name = 'ValidatorError';
Expand Down Expand Up @@ -436,7 +441,7 @@ CastError.prototype.__proto__ = MongooseError.prototype;
* type: Date
* } // My Birth Date
*
* If you don't like this format, supply `{path|Your own label}` in your error own message
* If you don't like this format, supply `{path|Your own label}` in your own error message
*
* name: {
* first: {
Expand Down

0 comments on commit 2f18ef5

Please sign in to comment.