diff --git a/test/schema.type.test.js b/test/schema.type.test.js index b1c37594576..d217615f3ce 100644 --- a/test/schema.type.test.js +++ b/test/schema.type.test.js @@ -87,4 +87,17 @@ describe('schematype', function() { assert.ifError(err); }); }); + + it('handles function as positional message arg (gh-8360)', function() { + const schema = Schema({ + name: { + type: String, + validate: [() => false, err => `${err.path} is invalid!`] + } + }); + + const err = schema.path('name').doValidateSync('test'); + assert.equal(err.name, 'ValidatorError'); + assert.equal(err.message, 'name is invalid!'); + }); });