1
0
mirror of synced 2025-01-19 17:01:43 +03:00

Fix default validation rule language for max to be more accurate.

Correct “max” variable name in max validation rule.
This commit is contained in:
Luan Nguyen 2020-02-28 14:26:14 -05:00
parent 50ff66f86f
commit 1528d45405
2 changed files with 7 additions and 7 deletions

View File

@ -140,19 +140,19 @@ export default {
/** /**
* Check the maximum value of a particular. * Check the maximum value of a particular.
*/ */
max: function ({ value }, minimum = 10, force) { max: function ({ value }, maximum = 10, force) {
return Promise.resolve((() => { return Promise.resolve((() => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
minimum = !isNaN(minimum) ? Number(minimum) : minimum maximum = !isNaN(maximum) ? Number(maximum) : maximum
return value.length <= minimum return value.length <= maximum
} }
if ((!isNaN(value) && force !== 'length') || force === 'value') { if ((!isNaN(value) && force !== 'length') || force === 'value') {
value = !isNaN(value) ? Number(value) : value value = !isNaN(value) ? Number(value) : value
return value <= minimum return value <= maximum
} }
if (typeof value === 'string' || (force === 'length')) { if (typeof value === 'string' || (force === 'length')) {
value = !isNaN(value) ? value.toString() : value value = !isNaN(value) ? value.toString() : value
return value.length <= minimum return value.length <= maximum
} }
return false return false
})()) })())

View File

@ -115,9 +115,9 @@ export default {
} }
const force = Array.isArray(args) && args[1] ? args[1] : false const force = Array.isArray(args) && args[1] ? args[1] : false
if ((!isNaN(value) && force !== 'length') || force === 'value') { 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.`
}, },
/** /**