@punks/backend-entity-manager 0.0.389 → 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 +30 -4
- 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 +30 -5
- 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
|
@@ -420,10 +420,14 @@ class EntitySerializer {
|
|
|
420
420
|
data,
|
|
421
421
|
sheetName: this.entityName,
|
|
422
422
|
columns: [
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
423
|
+
...(definition.sheet?.useTypeColumn
|
|
424
|
+
? [
|
|
425
|
+
{
|
|
426
|
+
header: "_type",
|
|
427
|
+
value: () => this.entityName,
|
|
428
|
+
},
|
|
429
|
+
]
|
|
430
|
+
: []),
|
|
427
431
|
...definition.columns.map((c) => ({
|
|
428
432
|
header: c.name,
|
|
429
433
|
value: (item) => {
|
|
@@ -40753,6 +40757,27 @@ const fieldRequiredValidator = (item, selector) => {
|
|
|
40753
40757
|
validationErrors: value ? [] : [{ errorCode: "required" }],
|
|
40754
40758
|
};
|
|
40755
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
|
+
};
|
|
40756
40781
|
const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {
|
|
40757
40782
|
const value = selector(item);
|
|
40758
40783
|
if (!value) {
|
|
@@ -44906,6 +44931,7 @@ exports.createExpressFileResponse = createExpressFileResponse;
|
|
|
44906
44931
|
exports.fieldOptionValidator = fieldOptionValidator;
|
|
44907
44932
|
exports.fieldOptionsValidator = fieldOptionsValidator;
|
|
44908
44933
|
exports.fieldRequiredValidator = fieldRequiredValidator;
|
|
44934
|
+
exports.fieldTextValidator = fieldTextValidator;
|
|
44909
44935
|
exports.getEntityManagerProviderToken = getEntityManagerProviderToken;
|
|
44910
44936
|
exports.getLocalizedText = getLocalizedText;
|
|
44911
44937
|
exports.newUuid = newUuid;
|