@linzjs/step-ag-grid 7.6.2 → 7.8.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/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/src/utils/textValidator.d.ts +8 -0
- package/dist/src/utils/textValidator.test.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +37 -7
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +7 -3
- package/src/utils/textValidator.test.ts +107 -0
- package/src/utils/textValidator.ts +47 -7
- package/src/utils/util.ts +1 -1
|
@@ -5,5 +5,13 @@ export interface TextInputValidatorProps<RowType extends GridBaseRow> {
|
|
|
5
5
|
maxLength?: number;
|
|
6
6
|
maxBytes?: number;
|
|
7
7
|
invalid?: (value: string, data: RowType, context: any) => JSX.Element | string | null;
|
|
8
|
+
numberFormat?: {
|
|
9
|
+
precision?: number;
|
|
10
|
+
scale?: number;
|
|
11
|
+
gtMin?: number;
|
|
12
|
+
geMin?: number;
|
|
13
|
+
ltMax?: number;
|
|
14
|
+
leMax?: number;
|
|
15
|
+
};
|
|
8
16
|
}
|
|
9
17
|
export declare const TextInputValidator: <RowType extends GridBaseRow>(props: TextInputValidatorProps<RowType>, value: string | null, data: RowType, context: any) => string | JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1306,7 +1306,7 @@ var wait$2 = function (timeoutMs) {
|
|
|
1306
1306
|
});
|
|
1307
1307
|
};
|
|
1308
1308
|
var isFloat = function (value) {
|
|
1309
|
-
var regexp = /^-?\d
|
|
1309
|
+
var regexp = /^-?\d*(\.\d+)?$/;
|
|
1310
1310
|
return regexp.test(value);
|
|
1311
1311
|
};
|
|
1312
1312
|
var findParentWithClass = function (className, child) {
|
|
@@ -4176,17 +4176,47 @@ var TextInputValidator = function (props, value, data, context) {
|
|
|
4176
4176
|
return null;
|
|
4177
4177
|
// This can happen because subcomponent is invoked without type safety
|
|
4178
4178
|
if (typeof value !== "string") {
|
|
4179
|
-
|
|
4180
|
-
return null;
|
|
4179
|
+
return "Value is not a string";
|
|
4181
4180
|
}
|
|
4182
|
-
if (props.required && value
|
|
4183
|
-
return "
|
|
4181
|
+
if (props.required && value == "") {
|
|
4182
|
+
return "Must not be empty";
|
|
4184
4183
|
}
|
|
4185
4184
|
if (props.maxLength && value.length > props.maxLength) {
|
|
4186
|
-
return "
|
|
4185
|
+
return "Must be no longer than ".concat(props.maxLength, " characters");
|
|
4187
4186
|
}
|
|
4188
4187
|
if (props.maxBytes && stringByteLengthIsInvalid(value, props.maxBytes)) {
|
|
4189
|
-
return "
|
|
4188
|
+
return "Must be no longer than ".concat(props.maxBytes, " bytes");
|
|
4189
|
+
}
|
|
4190
|
+
var nf = props.numberFormat;
|
|
4191
|
+
if (nf) {
|
|
4192
|
+
if (value != "" && !isFloat(value)) {
|
|
4193
|
+
return "Must be a valid number";
|
|
4194
|
+
}
|
|
4195
|
+
if (value != "") {
|
|
4196
|
+
var number = parseFloat(value);
|
|
4197
|
+
if (nf.gtMin != null && number <= nf.gtMin) {
|
|
4198
|
+
return "Must be greater than ".concat(nf.gtMin);
|
|
4199
|
+
}
|
|
4200
|
+
if (nf.geMin != null && number < nf.geMin) {
|
|
4201
|
+
return "Must not be less than ".concat(nf.geMin);
|
|
4202
|
+
}
|
|
4203
|
+
if (nf.ltMax != null && number >= nf.ltMax) {
|
|
4204
|
+
return "Must be less than ".concat(nf.ltMax);
|
|
4205
|
+
}
|
|
4206
|
+
if (nf.leMax != null && number > nf.leMax) {
|
|
4207
|
+
return "Must not be greater than ".concat(nf.leMax);
|
|
4208
|
+
}
|
|
4209
|
+
if (nf.precision != null && value != "") {
|
|
4210
|
+
if (parseFloat(number.toPrecision(nf.precision)) != number) {
|
|
4211
|
+
return "Must have no more than ".concat(nf.precision, " digits precision");
|
|
4212
|
+
}
|
|
4213
|
+
}
|
|
4214
|
+
if (nf.scale != null && value != "") {
|
|
4215
|
+
if (parseFloat(number.toFixed(nf.scale)) != number) {
|
|
4216
|
+
return nf.scale == 0 ? "Must be a whole number" : "Must have no more than ".concat(nf.scale, " decimal places");
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
}
|
|
4190
4220
|
}
|
|
4191
4221
|
if (props.invalid) {
|
|
4192
4222
|
return props.invalid(value, data, context);
|