pols-validator 2.3.6 → 2.3.7
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/rulesEngine.d.ts.map +1 -1
- package/dist/rulesEngine.js +11 -5
- package/package.json +1 -1
- package/src/rulesEngine.ts +10 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rulesEngine.d.ts","sourceRoot":"","sources":["../src/rulesEngine.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,CAAC;IACJ,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;AAExH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC/B,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,IAAI,CAAA;IACb,MAAM,EAAE,CAAC,CAAA;CACT,GAAG;IACH,KAAK,EAAE,IAAI,CAAA;IACX,OAAO,EAAE,KAAK,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,qBAAa,YAAY;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAQ;IACzB,OAAO,EAAE,OAAO,CAAO;IAE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AAE,OAAO,CAAQ;IACzB,OAAO,EAAE,OAAO,CAAO;IAEvB,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,eAAe,CAAe;gBAE1B,MAAM,CAAC,EAAE,YAAY;IAOjC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,cAAc;IAQ9D,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,UAAO,GAAG,cAAc,CAAC,CAAC,CAAC;CA2D5D"}
|
package/dist/rulesEngine.js
CHANGED
|
@@ -26,6 +26,7 @@ class PRulesEngine {
|
|
|
26
26
|
const errorMessages = [];
|
|
27
27
|
if (typeof target == 'string')
|
|
28
28
|
target = target.trim();
|
|
29
|
+
const defaultIsEmpty = this.default == null || (typeof this.default == 'string' && !this.default);
|
|
29
30
|
const isEmpty = target == null || (typeof target == 'string' && !target);
|
|
30
31
|
const label = this.label;
|
|
31
32
|
if (this.required && isEmpty) {
|
|
@@ -36,11 +37,16 @@ class PRulesEngine {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
if (isEmpty) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
if (!defaultIsEmpty) {
|
|
41
|
+
target = this.default;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return {
|
|
45
|
+
error: false,
|
|
46
|
+
success: true,
|
|
47
|
+
result: this.default
|
|
48
|
+
};
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
const wrapper = {
|
|
46
52
|
value: safe ? JSON.parse(JSON.stringify(target)) : target,
|
package/package.json
CHANGED
package/src/rulesEngine.ts
CHANGED
|
@@ -54,7 +54,9 @@ export class PRulesEngine {
|
|
|
54
54
|
|
|
55
55
|
if (typeof target == 'string') target = target.trim()
|
|
56
56
|
|
|
57
|
+
const defaultIsEmpty = this.default == null || (typeof this.default == 'string' && !this.default)
|
|
57
58
|
const isEmpty = target == null || (typeof target == 'string' && !target)
|
|
59
|
+
|
|
58
60
|
const label = this.label
|
|
59
61
|
|
|
60
62
|
if (this.required && isEmpty) {
|
|
@@ -66,10 +68,14 @@ export class PRulesEngine {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
if (isEmpty) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (!defaultIsEmpty) {
|
|
72
|
+
target = this.default
|
|
73
|
+
} else {
|
|
74
|
+
return {
|
|
75
|
+
error: false,
|
|
76
|
+
success: true,
|
|
77
|
+
result: this.default as T
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
|