@punks/backend-entity-manager 0.0.412 → 0.0.414

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 CHANGED
@@ -40984,17 +40984,17 @@ const fieldRequiredValidator = (item, selector) => {
40984
40984
  };
40985
40985
  const fieldTextValidator = (item, selector, params) => {
40986
40986
  const value = selector(item);
40987
+ const values = Array.isArray(value) ? value : [value];
40987
40988
  const isRequiredValid = params.required
40988
- ? typeof value === "string" && value.length >= 0
40989
+ ? values.length > 0 &&
40990
+ values.every((v) => typeof v === "string" && v.length > 0)
40989
40991
  : true;
40990
- const length = typeof value === "string" ? value.length : 0;
40991
- const isMinLengthValid = length >= (params.minLength ?? 0);
40992
- const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
40993
- const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
40994
- return {
40995
- isValid: isMinLengthValid && isMaxLengthValid && isRegexValid,
40996
- validationErrors: [
40997
- ...(isRequiredValid ? [] : [{ errorCode: "required" }]),
40992
+ const validateSingle = (v) => {
40993
+ const length = v.length;
40994
+ const isMinLengthValid = length >= (params.minLength ?? 0);
40995
+ const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
40996
+ const isRegexValid = params.regex?.test(v) ?? true;
40997
+ return [
40998
40998
  ...(isMinLengthValid
40999
40999
  ? []
41000
41000
  : [
@@ -41014,6 +41014,14 @@ const fieldTextValidator = (item, selector, params) => {
41014
41014
  ...(isRegexValid
41015
41015
  ? []
41016
41016
  : [{ errorCode: params.regexErrorCode ?? "regex" }]),
41017
+ ];
41018
+ };
41019
+ const allErrors = values.flatMap(validateSingle);
41020
+ return {
41021
+ isValid: isRequiredValid && allErrors.length === 0,
41022
+ validationErrors: [
41023
+ ...(isRequiredValid ? [] : [{ errorCode: "required" }]),
41024
+ ...allErrors,
41017
41025
  ],
41018
41026
  };
41019
41027
  };
@@ -41175,6 +41183,9 @@ let SendgridEmailProvider = class SendgridEmailProvider {
41175
41183
  this.client.setApiKey(sendgridSettings.value.apiKey);
41176
41184
  }
41177
41185
  async sendTemplatedEmail(input, template) {
41186
+ if (!input.to?.length && !input.cc?.length && !input.bcc?.length) {
41187
+ throw new Error(`No recipient specified for email ${input.templateId}`);
41188
+ }
41178
41189
  const processedPayload = await template.processPayload(input.payload);
41179
41190
  const templateData = await template.getTemplateData(processedPayload);
41180
41191
  if (templateData.type === "html") {