@punks/backend-entity-manager 0.0.413 → 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,19 +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 = ((!params.required && !value) ||
40994
- (typeof value === "string" && params.regex?.test(value))) ??
40995
- true;
40996
- return {
40997
- isValid: isMinLengthValid && isMaxLengthValid && isRegexValid && isRequiredValid,
40998
- validationErrors: [
40999
- ...(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 [
41000
40998
  ...(isMinLengthValid
41001
40999
  ? []
41002
41000
  : [
@@ -41016,6 +41014,14 @@ const fieldTextValidator = (item, selector, params) => {
41016
41014
  ...(isRegexValid
41017
41015
  ? []
41018
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,
41019
41025
  ],
41020
41026
  };
41021
41027
  };
@@ -41177,6 +41183,9 @@ let SendgridEmailProvider = class SendgridEmailProvider {
41177
41183
  this.client.setApiKey(sendgridSettings.value.apiKey);
41178
41184
  }
41179
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
+ }
41180
41189
  const processedPayload = await template.processPayload(input.payload);
41181
41190
  const templateData = await template.getTemplateData(processedPayload);
41182
41191
  if (templateData.type === "html") {