validator.js
917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*!
* Module dependencies.
*/
var MongooseError = require('../error');
/**
* Schema validator error
*
* @param {String} path
* @param {String} msg
* @param {String|Number|any} val
* @inherits MongooseError
* @api private
*/
function ValidatorError (path, type, val) {
var msg = type
? '"' + type + '" '
: '';
var message = 'Validator ' + msg + 'failed for path ' + path
if (2 < arguments.length) message += ' with value `' + String(val) + '`';
MongooseError.call(this, message);
Error.captureStackTrace(this, arguments.callee);
this.name = 'ValidatorError';
this.path = path;
this.type = type;
this.value = val;
};
/*!
* toString helper
*/
ValidatorError.prototype.toString = function () {
return this.message;
}
/*!
* Inherits from MongooseError
*/
ValidatorError.prototype.__proto__ = MongooseError.prototype;
/*!
* exports
*/
module.exports = ValidatorError;