Permalink
Browse files

MongooseError.type -> MongooseError.kind

  • Loading branch information...
1 parent 2b56741 commit 5e1d897ec45d99e0d2148a88eff183792725af8a Aaron Heckmann committed Dec 18, 2013
View
@@ -17,7 +17,7 @@ function CastError (type, value, path) {
MongooseError.call(this, 'Cast to ' + type + ' failed for value "' + value + '" at path "' + path + '"');
Error.captureStackTrace(this, arguments.callee);
this.name = 'CastError';
- this.type = type;
+ this.kind = type;
this.value = value;
this.path = path;
};
View
@@ -22,7 +22,7 @@ function ValidatorError (path, msg, type, val) {
Error.captureStackTrace(this, arguments.callee);
this.name = 'ValidatorError';
this.path = path;
- this.type = type;
+ this.kind = type;
this.value = val;
};
View
@@ -1018,7 +1018,7 @@ describe('document', function(){
assert.ok(err instanceof ValidationError);
assert.ok(err.errors.baz instanceof ValidatorError);
assert.equal(err.errors.baz.message,'validation failed for path baz');
- assert.equal(err.errors.baz.type,'user defined');
+ assert.equal(err.errors.baz.kind,'user defined');
assert.equal(err.errors.baz.path,'baz');
post.save(function(err){
@@ -1508,9 +1508,9 @@ describe('model: populate:', function(){
assert.ok('num' in err.errors);
assert.ok('str' in err.errors);
assert.ok('user' in err.errors);
- assert.equal(err.errors.num.type,'required');
- assert.equal(err.errors.str.type,'required');
- assert.equal(err.errors.user.type,'required');
+ assert.equal(err.errors.num.kind,'required');
+ assert.equal(err.errors.str.kind,'required');
+ assert.equal(err.errors.user.kind,'required');
comment.user = user;
comment.num = 1995;
View
@@ -1435,7 +1435,7 @@ describe('Model', function(){
post.save(function(err){
assert.ok(err instanceof MongooseError);
assert.ok(err instanceof ValidationError);
- assert.equal(err.errors.baz.type,'user defined');
+ assert.equal(err.errors.baz.kind,'user defined');
assert.equal(err.errors.baz.path,'baz');
post.set('baz', 'good');
@@ -1477,7 +1477,7 @@ describe('Model', function(){
post.save(function(err){
assert.ok(err instanceof MongooseError);
assert.ok(err instanceof ValidationError);
- assert.equal(err.errors.prop.type,'user defined');
+ assert.equal(err.errors.prop.kind,'user defined');
assert.equal(err.errors.prop.path,'prop');
post.set('prop', 'good');
@@ -1531,18 +1531,18 @@ describe('Model', function(){
assert.ok(err instanceof ValidationError);
assert.equal(4, Object.keys(err.errors).length);
assert.ok(err.errors.baz instanceof ValidatorError);
- assert.equal(err.errors.baz.type,'user defined');
+ assert.equal(err.errors.baz.kind,'user defined');
assert.equal(err.errors.baz.path,'baz');
assert.ok(err.errors.abc instanceof ValidatorError);
- assert.equal(err.errors.abc.type,'user defined');
+ assert.equal(err.errors.abc.kind,'user defined');
assert.equal(err.errors.abc.message,'must be abc');
assert.equal(err.errors.abc.path,'abc');
assert.ok(err.errors.test instanceof ValidatorError);
assert.equal(err.errors.test.message,'must also be abc');
- assert.equal(err.errors.test.type,'user defined');
+ assert.equal(err.errors.test.kind,'user defined');
assert.equal(err.errors.test.path,'test');
assert.ok(err.errors.required instanceof ValidatorError);
- assert.equal(err.errors.required.type,'required');
+ assert.equal(err.errors.required.kind,'required');
assert.equal(err.errors.required.path,'required');
post.set({
@@ -157,7 +157,7 @@ describe('schema', function(){
Tobi.path('friends').doValidate(100, function(err){
assert.ok(err instanceof ValidatorError);
assert.equal('friends', err.path);
- assert.equal('max', err.type);
+ assert.equal('max', err.kind);
assert.equal(100, err.value);
});
@@ -475,7 +475,7 @@ describe('schema', function(){
m.validate(function (err) {
assert.equal('x failed validation (3,4,5,6)', String(err.errors.x));
- assert.equal('user defined', err.errors.x.type);
+ assert.equal('user defined', err.errors.x.kind);
done();
})
})
@@ -67,24 +67,24 @@ describe('types.buffer', function(){
t.validate(function (err) {
assert.equal(err.message,'Validation failed');
- assert.equal(err.errors.required.type,'required');
+ assert.equal(err.errors.required.kind,'required');
t.required = {x:[20]}
t.save(function (err) {
assert.ok(err);
assert.equal(err.name, 'CastError');
- assert.equal(err.type, 'buffer');
+ assert.equal(err.kind, 'buffer');
assert.equal(err.message, 'Cast to buffer failed for value "[object Object]" at path "required"');
assert.deepEqual(err.value, {x:[20]});
t.required = new Buffer("hello");
t.sub.push({ name: 'Friday Friday' });
t.save(function (err) {
assert.equal(err.message,'Validation failed');
- assert.equal(err.errors['sub.0.buf'].type,'required');
+ assert.equal(err.errors['sub.0.buf'].kind,'required');
t.sub[0].buf = new Buffer("well well");
t.save(function (err) {
assert.equal(err.message,'Validation failed');
- assert.equal(err.errors['sub.0.buf'].type,'user defined');
+ assert.equal(err.errors['sub.0.buf'].kind,'user defined');
assert.equal(err.errors['sub.0.buf'].message,'valid failed');
t.sub[0].buf = new Buffer("well well well");
@@ -398,7 +398,7 @@ describe('types.documentarray', function(){
var e = t.errors['docs.0.name'];
assert.ok(e);
assert.equal(e.path, 'docs.0.name');
- assert.equal(e.type, 'user defined');
+ assert.equal(e.kind, 'user defined');
assert.equal(e.message, 'boo boo');
assert.equal(e.value, '%');
done();

0 comments on commit 5e1d897

Please sign in to comment.