Validator max & min not working at the same time
matej116 opened this issue · comments
Matěj Polák commented
Both validators max and min are using the range validator, when the min and max validator are used at the same time. The range validator will fail on the first one since it is checking elem.validity.overflow/underflow flags and the error message of the first failed validator is issued.
This implementation of range validator would solve the issue:
range: function(elem, arg, val) {
if (elem.type === 'number') {
if ((elem.validity.rangeUnderflow && arg[0] !== null) || (elem.validity.rangeOverflow && arg[1] !== null)) {
debugger;
return false
} else if (elem.validity.badInput) {
return null;
}
}
return Nette.isArray(arg) ?
((arg[0] === null || parseFloat(val) >= arg[0]) && (arg[1] === null || parseFloat(val) <= arg[1])) : null;
},
The only change is check for arg[0] !== null and arg[1] !== null.
Milan Felix Šulc commented
Resolved via c3b82a9