@punks/backend-entity-manager 0.0.410 → 0.0.412

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.
@@ -5,6 +5,7 @@ export declare const fieldTextValidator: <TSheetItem>(item: TSheetItem, selector
5
5
  minLength?: number;
6
6
  maxLength?: number;
7
7
  regex?: RegExp;
8
+ regexErrorCode?: string;
8
9
  }) => EntryValidationResult;
9
10
  export declare const fieldEmailValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => any, params: {
10
11
  required?: boolean;
package/dist/esm/index.js CHANGED
@@ -40977,7 +40977,7 @@ const fieldTextValidator = (item, selector, params) => {
40977
40977
  const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
40978
40978
  const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
40979
40979
  return {
40980
- isValid: isMinLengthValid && isMaxLengthValid,
40980
+ isValid: isMinLengthValid && isMaxLengthValid && isRegexValid,
40981
40981
  validationErrors: [
40982
40982
  ...(isRequiredValid ? [] : [{ errorCode: "required" }]),
40983
40983
  ...(isMinLengthValid
@@ -40996,7 +40996,9 @@ const fieldTextValidator = (item, selector, params) => {
40996
40996
  payload: { current: length, expected: params.maxLength },
40997
40997
  },
40998
40998
  ]),
40999
- ...(isRegexValid ? [] : [{ errorCode: "regex" }]),
40999
+ ...(isRegexValid
41000
+ ? []
41001
+ : [{ errorCode: params.regexErrorCode ?? "regex" }]),
41000
41002
  ],
41001
41003
  };
41002
41004
  };
@@ -41004,6 +41006,7 @@ const fieldEmailValidator = (item, selector, params) => {
41004
41006
  return fieldTextValidator(item, selector, {
41005
41007
  ...params,
41006
41008
  regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
41009
+ regexErrorCode: "email",
41007
41010
  });
41008
41011
  };
41009
41012
  const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {