From 253e054834d03ff282f4b4848d12ec734c8551dd Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 4 Dec 2019 10:53:59 -0500 Subject: [PATCH] test(schematype): repro #8360 --- test/schema.type.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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!'); + }); });