@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/cjs/index.js
CHANGED
|
@@ -40762,18 +40762,30 @@ const fieldTextValidator = (item, selector, params) => {
|
|
|
40762
40762
|
const isRequiredValid = params.required
|
|
40763
40763
|
? typeof value === "string" && value.length >= 0
|
|
40764
40764
|
: true;
|
|
40765
|
-
const
|
|
40766
|
-
const
|
|
40765
|
+
const length = typeof value === "string" ? value.length : 0;
|
|
40766
|
+
const isMinLengthValid = length >= (params.minLength ?? 0);
|
|
40767
|
+
const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
|
|
40767
40768
|
const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
|
|
40768
40769
|
return {
|
|
40769
40770
|
isValid: isMinLengthValid && isMaxLengthValid,
|
|
40770
40771
|
validationErrors: [
|
|
40771
40772
|
...(isRequiredValid ? [] : [{ errorCode: "required" }]),
|
|
40772
|
-
...(isMinLengthValid
|
|
40773
|
+
...(isMinLengthValid
|
|
40773
40774
|
? []
|
|
40774
|
-
: [
|
|
40775
|
-
|
|
40776
|
-
|
|
40775
|
+
: [
|
|
40776
|
+
{
|
|
40777
|
+
errorCode: "minLength",
|
|
40778
|
+
payload: { current: length, expected: params.minLength },
|
|
40779
|
+
},
|
|
40780
|
+
]),
|
|
40781
|
+
...(isMaxLengthValid
|
|
40782
|
+
? []
|
|
40783
|
+
: [
|
|
40784
|
+
{
|
|
40785
|
+
errorCode: "maxLength",
|
|
40786
|
+
payload: { current: length, expected: params.maxLength },
|
|
40787
|
+
},
|
|
40788
|
+
]),
|
|
40777
40789
|
...(isRegexValid ? [] : [{ errorCode: "regex" }]),
|
|
40778
40790
|
],
|
|
40779
40791
|
};
|