@punks/backend-entity-manager 0.0.411 → 0.0.413

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
@@ -40990,9 +40990,11 @@ const fieldTextValidator = (item, selector, params) => {
40990
40990
  const length = typeof value === "string" ? value.length : 0;
40991
40991
  const isMinLengthValid = length >= (params.minLength ?? 0);
40992
40992
  const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
40993
- const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
40993
+ const isRegexValid = ((!params.required && !value) ||
40994
+ (typeof value === "string" && params.regex?.test(value))) ??
40995
+ true;
40994
40996
  return {
40995
- isValid: isMinLengthValid && isMaxLengthValid && isRegexValid,
40997
+ isValid: isMinLengthValid && isMaxLengthValid && isRegexValid && isRequiredValid,
40996
40998
  validationErrors: [
40997
40999
  ...(isRequiredValid ? [] : [{ errorCode: "required" }]),
40998
41000
  ...(isMinLengthValid
@@ -41011,7 +41013,9 @@ const fieldTextValidator = (item, selector, params) => {
41011
41013
  payload: { current: length, expected: params.maxLength },
41012
41014
  },
41013
41015
  ]),
41014
- ...(isRegexValid ? [] : [{ errorCode: "regex" }]),
41016
+ ...(isRegexValid
41017
+ ? []
41018
+ : [{ errorCode: params.regexErrorCode ?? "regex" }]),
41015
41019
  ],
41016
41020
  };
41017
41021
  };
@@ -41019,6 +41023,7 @@ const fieldEmailValidator = (item, selector, params) => {
41019
41023
  return fieldTextValidator(item, selector, {
41020
41024
  ...params,
41021
41025
  regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
41026
+ regexErrorCode: "email",
41022
41027
  });
41023
41028
  };
41024
41029
  const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {