MCPcopy
hub / github.com/autoNumeric/autoNumeric / _checkIfInRangeWithOverrideOption

Method _checkIfInRangeWithOverrideOption

src/AutoNumeric.js:6041–6067  ·  view source on GitHub ↗

* Check if the given value is within the `minimumValue` and `maximumValue` range, while using the override options set with `overrideMinMaxLimits`. * The minimum and maximum limit test results are returned in an array like `[isMinimumLimitRespected, isMaximumLimitRespected]`. * * @par

(value, settings)

Source from the content-addressed store, hash-verified

6039 * @returns {[boolean, boolean]}
6040 */
6041 static _checkIfInRangeWithOverrideOption(value, settings) {
6042 if ((AutoNumericHelper.isNull(value) && settings.emptyInputBehavior === AutoNumeric.options.emptyInputBehavior.null) || // When the `null` value is accepted as the `rawValue`, the limits are ignored
6043 settings.overrideMinMaxLimits === AutoNumeric.options.overrideMinMaxLimits.ignore ||
6044 settings.overrideMinMaxLimits === AutoNumeric.options.overrideMinMaxLimits.invalid) {
6045 return [true, true];
6046 }
6047
6048 value = value.toString();
6049 value = value.replace(',', '.');
6050 const minParse = AutoNumericHelper.parseStr(settings.minimumValue);
6051 const maxParse = AutoNumericHelper.parseStr(settings.maximumValue);
6052 const valParse = AutoNumericHelper.parseStr(value);
6053
6054 let result;
6055 switch (settings.overrideMinMaxLimits) {
6056 case AutoNumeric.options.overrideMinMaxLimits.floor:
6057 result = [AutoNumericHelper.testMinMax(minParse, valParse) > -1, true];
6058 break;
6059 case AutoNumeric.options.overrideMinMaxLimits.ceiling:
6060 result = [true, AutoNumericHelper.testMinMax(maxParse, valParse) < 1];
6061 break;
6062 default:
6063 result = [AutoNumericHelper.testMinMax(minParse, valParse) > -1, AutoNumericHelper.testMinMax(maxParse, valParse) < 1];
6064 }
6065
6066 return result;
6067 }
6068
6069 /**
6070 * Returns `true` if the given value is within the `minimumValue` and `maximumValue` limits, while using the override options set with `overrideMinMaxLimits`, `false` otherwise

Callers 4

setMethod · 0.80
_setValuePartsMethod · 0.80

Calls 3

isNullMethod · 0.80
parseStrMethod · 0.80
testMinMaxMethod · 0.80

Tested by

no test coverage detected