@punks/backend-entity-manager 0.0.390 → 0.0.391
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 +22 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/index.d.ts +1 -1
- package/dist/cjs/types/utils/validators.d.ts +6 -0
- package/dist/esm/index.js +22 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/index.d.ts +1 -1
- package/dist/esm/types/utils/validators.d.ts +6 -0
- package/dist/index.d.ts +7 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -40757,6 +40757,27 @@ const fieldRequiredValidator = (item, selector) => {
|
|
|
40757
40757
|
validationErrors: value ? [] : [{ errorCode: "required" }],
|
|
40758
40758
|
};
|
|
40759
40759
|
};
|
|
40760
|
+
const fieldTextValidator = (item, selector, params) => {
|
|
40761
|
+
const value = selector(item);
|
|
40762
|
+
const isRequiredValid = params.required
|
|
40763
|
+
? typeof value === "string" && value.length >= 0
|
|
40764
|
+
: true;
|
|
40765
|
+
const isMinLengthValid = typeof value === "string" && value.length >= (params.minLength ?? 0);
|
|
40766
|
+
const isMaxLengthValid = typeof value === "string" && value.length <= (params.maxLength ?? Infinity);
|
|
40767
|
+
const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
|
|
40768
|
+
return {
|
|
40769
|
+
isValid: isMinLengthValid && isMaxLengthValid,
|
|
40770
|
+
validationErrors: [
|
|
40771
|
+
...(isRequiredValid ? [] : [{ errorCode: "required" }]),
|
|
40772
|
+
...(isMinLengthValid && isMaxLengthValid
|
|
40773
|
+
? []
|
|
40774
|
+
: [{ errorCode: "length" }]),
|
|
40775
|
+
...(isMinLengthValid ? [] : [{ errorCode: "minLength" }]),
|
|
40776
|
+
...(isMaxLengthValid ? [] : [{ errorCode: "maxLength" }]),
|
|
40777
|
+
...(isRegexValid ? [] : [{ errorCode: "regex" }]),
|
|
40778
|
+
],
|
|
40779
|
+
};
|
|
40780
|
+
};
|
|
40760
40781
|
const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {
|
|
40761
40782
|
const value = selector(item);
|
|
40762
40783
|
if (!value) {
|
|
@@ -44910,6 +44931,7 @@ exports.createExpressFileResponse = createExpressFileResponse;
|
|
|
44910
44931
|
exports.fieldOptionValidator = fieldOptionValidator;
|
|
44911
44932
|
exports.fieldOptionsValidator = fieldOptionsValidator;
|
|
44912
44933
|
exports.fieldRequiredValidator = fieldRequiredValidator;
|
|
44934
|
+
exports.fieldTextValidator = fieldTextValidator;
|
|
44913
44935
|
exports.getEntityManagerProviderToken = getEntityManagerProviderToken;
|
|
44914
44936
|
exports.getLocalizedText = getLocalizedText;
|
|
44915
44937
|
exports.newUuid = newUuid;
|