@linzjs/step-ag-grid 14.6.0 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/utils/textValidator.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +19 -6
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/textValidator.test.ts +7 -0
- package/src/utils/textValidator.ts +8 -4
- package/src/utils/util.test.ts +12 -1
- package/src/utils/util.ts +11 -2
|
@@ -12,6 +12,7 @@ export interface TextInputValidatorProps<RowType extends GridBaseRow> {
|
|
|
12
12
|
geMin?: number;
|
|
13
13
|
ltMax?: number;
|
|
14
14
|
leMax?: number;
|
|
15
|
+
notZero?: boolean;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export declare const TextInputValidator: <RowType extends GridBaseRow>(props: TextInputValidatorProps<RowType>, value: string | null, data: RowType, context: any) => string | JSX.Element | null;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -475,9 +475,19 @@ var wait$2 = function (timeoutMs) {
|
|
|
475
475
|
setTimeout(resolve, timeoutMs);
|
|
476
476
|
});
|
|
477
477
|
};
|
|
478
|
+
// This regexp only works if you parseFloat first, it won't validate a float on its own
|
|
479
|
+
// It prevents scientific 1e10, or trailing decimal 1.2.3, or trailing garbage 1.2xyz
|
|
480
|
+
var isFloatRegExp = /^-?\d*\.?\d*$/;
|
|
478
481
|
var isFloat = function (value) {
|
|
479
|
-
|
|
480
|
-
|
|
482
|
+
try {
|
|
483
|
+
// Just checking it's not scientific notation or "NaN" here.
|
|
484
|
+
// Also parse float will parse up to the first invalid character,
|
|
485
|
+
// so we need to check there's no remaining invalids e.g. "1.2xyz" would parse as 1.2
|
|
486
|
+
return !Number.isNaN(parseFloat(value)) && isFloatRegExp.test(value);
|
|
487
|
+
}
|
|
488
|
+
catch (_a) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
481
491
|
};
|
|
482
492
|
var findParentWithClass = function (className, child) {
|
|
483
493
|
for (var node = child; node; node = node.parentNode) {
|
|
@@ -4458,17 +4468,20 @@ var TextInputValidator = function (props, value, data, context) {
|
|
|
4458
4468
|
}
|
|
4459
4469
|
if (value != "") {
|
|
4460
4470
|
var number = parseFloat(value);
|
|
4471
|
+
if (nf.notZero && number === 0) {
|
|
4472
|
+
return "Must not be 0";
|
|
4473
|
+
}
|
|
4461
4474
|
if (nf.gtMin != null && number <= nf.gtMin) {
|
|
4462
|
-
return "Must be greater than ".concat(nf.gtMin);
|
|
4475
|
+
return "Must be greater than ".concat(nf.gtMin.toLocaleString());
|
|
4463
4476
|
}
|
|
4464
4477
|
if (nf.geMin != null && number < nf.geMin) {
|
|
4465
|
-
return "Must not be less than ".concat(nf.geMin);
|
|
4478
|
+
return "Must not be less than ".concat(nf.geMin.toLocaleString());
|
|
4466
4479
|
}
|
|
4467
4480
|
if (nf.ltMax != null && number >= nf.ltMax) {
|
|
4468
|
-
return "Must be less than ".concat(nf.ltMax);
|
|
4481
|
+
return "Must be less than ".concat(nf.ltMax.toLocaleString());
|
|
4469
4482
|
}
|
|
4470
4483
|
if (nf.leMax != null && number > nf.leMax) {
|
|
4471
|
-
return "Must not be greater than ".concat(nf.leMax);
|
|
4484
|
+
return "Must not be greater than ".concat(nf.leMax.toLocaleString());
|
|
4472
4485
|
}
|
|
4473
4486
|
if (nf.precision != null && value != "") {
|
|
4474
4487
|
if (parseFloat(number.toPrecision(nf.precision)) != number) {
|