From ae602f03eab4ad24922f72d6d2df68e07270182a Mon Sep 17 00:00:00 2001 From: matvii Date: Sat, 19 Sep 2020 13:57:53 +0300 Subject: [PATCH] Remove typeof comparing to undefined This comparison is invalid, because typeof always returns strings. --- lib/validate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index 690d9eb..824a4b8 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -168,11 +168,11 @@ var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*O if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){ addError("must be at least " + schema.minLength + " characters long"); } - if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum && + if(typeof schema.minimum !== 'undefined' && typeof value == typeof schema.minimum && schema.minimum > value){ addError("must have a minimum value of " + schema.minimum); } - if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum && + if(typeof schema.maximum !== 'undefined' && typeof value == typeof schema.maximum && schema.maximum < value){ addError("must have a maximum value of " + schema.maximum); }