From 1528d454057c256b333538830d1770de60f2d2a2 Mon Sep 17 00:00:00 2001 From: Luan Nguyen Date: Fri, 28 Feb 2020 14:26:14 -0500 Subject: [PATCH] Fix default validation rule language for max to be more accurate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correct “max” variable name in max validation rule. --- src/libs/rules.js | 10 +++++----- src/locales/en.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/rules.js b/src/libs/rules.js index 1aa7076..c6b2146 100644 --- a/src/libs/rules.js +++ b/src/libs/rules.js @@ -140,19 +140,19 @@ export default { /** * Check the maximum value of a particular. */ - max: function ({ value }, minimum = 10, force) { + max: function ({ value }, maximum = 10, force) { return Promise.resolve((() => { if (Array.isArray(value)) { - minimum = !isNaN(minimum) ? Number(minimum) : minimum - return value.length <= minimum + maximum = !isNaN(maximum) ? Number(maximum) : maximum + return value.length <= maximum } if ((!isNaN(value) && force !== 'length') || force === 'value') { value = !isNaN(value) ? Number(value) : value - return value <= minimum + return value <= maximum } if (typeof value === 'string' || (force === 'length')) { value = !isNaN(value) ? value.toString() : value - return value.length <= minimum + return value.length <= maximum } return false })()) diff --git a/src/locales/en.js b/src/locales/en.js index 95088a4..aa9b5f1 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -115,9 +115,9 @@ export default { } const force = Array.isArray(args) && args[1] ? args[1] : false if ((!isNaN(value) && force !== 'length') || force === 'value') { - return `${s(name)} must be less than ${args[0]}.` + return `${s(name)} must be less than or equal to ${args[0]}.` } - return `${s(name)} must be less than ${args[0]} characters long.` + return `${s(name)} must be less than or equal to ${args[0]} characters long.` }, /**