procode-lowcode-core 1.0.10 → 1.0.11
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.esm.js +309 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +309 -5
- package/dist/index.js.map +1 -1
- package/dist/types/Validation/IValidationFactory.d.ts +9 -1
- package/dist/types/Validation/StandardValidations/StandardValidationFactory.d.ts +24 -0
- package/dist/types/Validation/StandardValidations/betweenValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/comparisonValidationHelper.d.ts +20 -0
- package/dist/types/Validation/StandardValidations/greaterThanEqualValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/greaterThanValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/lessThanEqualValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/lessThanValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/maxCharCountValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/minCharCountValidation.d.ts +5 -0
- package/dist/types/Validation/StandardValidations/notBetweenValidation.d.ts +5 -0
- package/dist/types/Validation/Types.d.ts +1 -0
- package/package.json +1 -1
- package/src/Action/StandardActions/handleAPICreate.ts +19 -4
- package/src/Validation/IValidationFactory.ts +8 -0
- package/src/Validation/StandardValidations/StandardValidationFactory.ts +16 -0
- package/src/Validation/StandardValidations/betweenValidation.ts +62 -0
- package/src/Validation/StandardValidations/comparisonValidationHelper.ts +74 -0
- package/src/Validation/StandardValidations/greaterThanEqualValidation.ts +49 -0
- package/src/Validation/StandardValidations/greaterThanValidation.ts +48 -0
- package/src/Validation/StandardValidations/lessThanEqualValidation.ts +49 -0
- package/src/Validation/StandardValidations/lessThanValidation.ts +48 -0
- package/src/Validation/StandardValidations/maxCharCountValidation.ts +27 -0
- package/src/Validation/StandardValidations/minCharCountValidation.ts +27 -0
- package/src/Validation/StandardValidations/notBetweenValidation.ts +62 -0
- package/src/Validation/Types.ts +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ValidationFcProperties } from "../Types";
|
|
2
|
+
import {
|
|
3
|
+
resolveCompareValue,
|
|
4
|
+
parseValue,
|
|
5
|
+
formatValueForMessage,
|
|
6
|
+
isEmpty,
|
|
7
|
+
} from "./comparisonValidationHelper";
|
|
8
|
+
|
|
9
|
+
export const notBetweenValidation = ({
|
|
10
|
+
validation,
|
|
11
|
+
viewModel,
|
|
12
|
+
value,
|
|
13
|
+
}: ValidationFcProperties): { isValid: boolean; message: string } => {
|
|
14
|
+
const {
|
|
15
|
+
minValue,
|
|
16
|
+
minFieldPath,
|
|
17
|
+
maxValue,
|
|
18
|
+
maxFieldPath,
|
|
19
|
+
dataType = "number",
|
|
20
|
+
} = validation.params || {};
|
|
21
|
+
|
|
22
|
+
if (minValue === undefined && !minFieldPath) {
|
|
23
|
+
console.error(
|
|
24
|
+
"NOT_BETWEEN validation requires 'minValue' or 'minFieldPath' in params"
|
|
25
|
+
);
|
|
26
|
+
return { isValid: false, message: "Validation misconfigured: min boundary is missing" };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (maxValue === undefined && !maxFieldPath) {
|
|
30
|
+
console.error(
|
|
31
|
+
"NOT_BETWEEN validation requires 'maxValue' or 'maxFieldPath' in params"
|
|
32
|
+
);
|
|
33
|
+
return { isValid: false, message: "Validation misconfigured: max boundary is missing" };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (isEmpty(value)) return { isValid: true, message: "" };
|
|
37
|
+
|
|
38
|
+
const rawMin = resolveCompareValue(minValue, minFieldPath, viewModel);
|
|
39
|
+
const rawMax = resolveCompareValue(maxValue, maxFieldPath, viewModel);
|
|
40
|
+
|
|
41
|
+
if (isEmpty(rawMin) || isEmpty(rawMax)) return { isValid: true, message: "" };
|
|
42
|
+
|
|
43
|
+
const parsedValue = parseValue(value, dataType);
|
|
44
|
+
const parsedMin = parseValue(rawMin, dataType);
|
|
45
|
+
const parsedMax = parseValue(rawMax, dataType);
|
|
46
|
+
|
|
47
|
+
if (parsedValue === null || parsedMin === null || parsedMax === null) {
|
|
48
|
+
return { isValid: false, message: validation.message || `Invalid ${dataType} value` };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isValid = parsedValue < parsedMin || parsedValue > parsedMax;
|
|
52
|
+
const minLabel = formatValueForMessage(rawMin, dataType);
|
|
53
|
+
const maxLabel = formatValueForMessage(rawMax, dataType);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
isValid,
|
|
57
|
+
message: isValid
|
|
58
|
+
? ""
|
|
59
|
+
: validation.message ||
|
|
60
|
+
`Value must not be between ${minLabel} and ${maxLabel}`,
|
|
61
|
+
};
|
|
62
|
+
};
|