@punks/backend-entity-manager 0.0.391 → 0.0.392
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/cjs/index.js +18 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -0
- package/dist/esm/index.js +18 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/serializer.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -40747,18 +40747,30 @@ const fieldTextValidator = (item, selector, params) => {
|
|
|
40747
40747
|
const isRequiredValid = params.required
|
|
40748
40748
|
? typeof value === "string" && value.length >= 0
|
|
40749
40749
|
: true;
|
|
40750
|
-
const
|
|
40751
|
-
const
|
|
40750
|
+
const length = typeof value === "string" ? value.length : 0;
|
|
40751
|
+
const isMinLengthValid = length >= (params.minLength ?? 0);
|
|
40752
|
+
const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
|
|
40752
40753
|
const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
|
|
40753
40754
|
return {
|
|
40754
40755
|
isValid: isMinLengthValid && isMaxLengthValid,
|
|
40755
40756
|
validationErrors: [
|
|
40756
40757
|
...(isRequiredValid ? [] : [{ errorCode: "required" }]),
|
|
40757
|
-
...(isMinLengthValid
|
|
40758
|
+
...(isMinLengthValid
|
|
40758
40759
|
? []
|
|
40759
|
-
: [
|
|
40760
|
-
|
|
40761
|
-
|
|
40760
|
+
: [
|
|
40761
|
+
{
|
|
40762
|
+
errorCode: "minLength",
|
|
40763
|
+
payload: { current: length, expected: params.minLength },
|
|
40764
|
+
},
|
|
40765
|
+
]),
|
|
40766
|
+
...(isMaxLengthValid
|
|
40767
|
+
? []
|
|
40768
|
+
: [
|
|
40769
|
+
{
|
|
40770
|
+
errorCode: "maxLength",
|
|
40771
|
+
payload: { current: length, expected: params.maxLength },
|
|
40772
|
+
},
|
|
40773
|
+
]),
|
|
40762
40774
|
...(isRegexValid ? [] : [{ errorCode: "regex" }]),
|
|
40763
40775
|
],
|
|
40764
40776
|
};
|