@punks/backend-entity-manager 0.0.378 → 0.0.379
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 +39 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -0
- package/dist/cjs/types/utils/index.d.ts +1 -1
- package/dist/cjs/types/utils/validators.d.ts +9 -0
- package/dist/esm/index.js +38 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/serializer.d.ts +1 -0
- package/dist/esm/types/utils/index.d.ts +1 -1
- package/dist/esm/types/utils/validators.d.ts +9 -0
- package/dist/index.d.ts +12 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -40721,6 +40721,43 @@ const fieldRequiredValidator = (item, selector) => {
|
|
|
40721
40721
|
validationErrors: value ? [] : [{ errorCode: "required" }],
|
|
40722
40722
|
};
|
|
40723
40723
|
};
|
|
40724
|
+
const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {
|
|
40725
|
+
const value = selector(item);
|
|
40726
|
+
if (!value) {
|
|
40727
|
+
return {
|
|
40728
|
+
isValid: true,
|
|
40729
|
+
validationErrors: [],
|
|
40730
|
+
};
|
|
40731
|
+
}
|
|
40732
|
+
const errors = [];
|
|
40733
|
+
const isValidOption = availableOptions.includes(value);
|
|
40734
|
+
if (!isValidOption) {
|
|
40735
|
+
errors.push({ errorCode: "invalidOption" });
|
|
40736
|
+
}
|
|
40737
|
+
if (required && !value) {
|
|
40738
|
+
errors.push({ errorCode: "required" });
|
|
40739
|
+
}
|
|
40740
|
+
return {
|
|
40741
|
+
isValid: errors.length === 0,
|
|
40742
|
+
validationErrors: errors,
|
|
40743
|
+
};
|
|
40744
|
+
};
|
|
40745
|
+
const fieldOptionsValidator = (item, selector, { availableOptions, minSelected, maxSelected, }) => {
|
|
40746
|
+
const values = selector(item);
|
|
40747
|
+
const errors = [];
|
|
40748
|
+
const invalidOptions = values.filter((x) => !availableOptions.includes(x));
|
|
40749
|
+
invalidOptions.forEach((x) => errors.push({ errorCode: "invalidOption", value: x }));
|
|
40750
|
+
if (minSelected && values.length < minSelected) {
|
|
40751
|
+
errors.push({ errorCode: "minSelected" });
|
|
40752
|
+
}
|
|
40753
|
+
if (maxSelected && values.length > maxSelected) {
|
|
40754
|
+
errors.push({ errorCode: "maxSelected" });
|
|
40755
|
+
}
|
|
40756
|
+
return {
|
|
40757
|
+
isValid: errors.length === 0,
|
|
40758
|
+
validationErrors: errors,
|
|
40759
|
+
};
|
|
40760
|
+
};
|
|
40724
40761
|
|
|
40725
40762
|
const createClient$2 = (settings) => new clientSes.SESClient({
|
|
40726
40763
|
region: settings.region,
|
|
@@ -44834,6 +44871,8 @@ exports.buildProviderToken = buildProviderToken;
|
|
|
44834
44871
|
exports.buildRolesGuard = buildRolesGuard;
|
|
44835
44872
|
exports.createContainer = createContainer;
|
|
44836
44873
|
exports.createExpressFileResponse = createExpressFileResponse;
|
|
44874
|
+
exports.fieldOptionValidator = fieldOptionValidator;
|
|
44875
|
+
exports.fieldOptionsValidator = fieldOptionsValidator;
|
|
44837
44876
|
exports.fieldRequiredValidator = fieldRequiredValidator;
|
|
44838
44877
|
exports.getEntityManagerProviderToken = getEntityManagerProviderToken;
|
|
44839
44878
|
exports.getLocalizedText = getLocalizedText;
|