diff --git a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.test.tsx b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.test.tsx index 3466b486f..e724b3e05 100644 --- a/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.test.tsx +++ b/client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.test.tsx @@ -79,4 +79,16 @@ test("textInputValidate", () => { validateStatus: "error", help: trans("validationDesc.maxLength", { length: 4, maxLength: 2 }), }); + + expect( + textInputValidate({ + value: { value: "" }, + required: false, + minLength: 0, + maxLength: 0, + validationType: "Regex", + regex: new RegExp("^.*$"), + customRule: "", + }) + ).toMatchObject({ validateStatus: "" }); }); diff --git a/client/packages/lowcoder/src/comps/controls/codeControl.tsx b/client/packages/lowcoder/src/comps/controls/codeControl.tsx index 7daa097d5..36788b842 100644 --- a/client/packages/lowcoder/src/comps/controls/codeControl.tsx +++ b/client/packages/lowcoder/src/comps/controls/codeControl.tsx @@ -281,7 +281,8 @@ function toRegExp(value: unknown): RegExp { return value as RegExp; } else if (valueType === "string") { const regexStr = trimStart(value as string, "^"); - return new RegExp("^" + (regexStr ?? ".*") + "$"); + const finalRegexStr = regexStr || ".*"; + return new RegExp("^" + finalRegexStr + "$"); } throw new TypeError( `must be a valid JavaScript regular expression without forward slashes around the pattern`