From 7b127221b04451b913f9b0f244c835d3cfe256a4 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 17 Nov 2015 17:40:12 +0200 Subject: [PATCH] tweak: Improved error messages when a binary object fails validation --- lib/Validators.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Validators.ts b/lib/Validators.ts index dca92c7..e0ebb49 100644 --- a/lib/Validators.ts +++ b/lib/Validators.ts @@ -7,7 +7,7 @@ export function DefaultValidators() { return this.assert(!data || data instanceof MongoDB.ObjectID || (data._bsontype === 'ObjectID' && data.id)); }, { name: 'ObjectID validation' }), Skmatc.create(schema => schema === Buffer, function(schema, data) { - return this.assert(data && (data instanceof MongoDB.Binary || (data._bsontype === 'Binary' && data.buffer))); + return this.assert(data && (data instanceof MongoDB.Binary || (data._bsontype === 'Binary' && data.buffer)), "Expected " + JSON.stringify(data) + " to be a valid buffer or MongoDB.Binary object"); }, { name: 'Buffer validation' }) ]; } \ No newline at end of file