fix(frontend): regex input control

This commit is contained in:
yassinedorbozgithub 2024-10-21 11:23:19 +01:00
parent 95f45b75ef
commit c4a1c16b94

View File

@ -266,9 +266,16 @@ const PatternInput: FC<PatternInputProps> = ({
{typeof value === "string" && patternType === "regex" ? (
<RegexInput
{...registerInput(t("message.regex_is_invalid"), idx, {
validate: (value) =>
(value.trim() !== "" && value !== "/") ??
t("message.regex_is_invalid"),
validate: (pattern) => {
try {
if (typeof pattern === "string")
new RegExp(pattern.slice(1, -1));
return true;
} catch (_e) {
return t("message.regex_is_invalid");
}
},
setValueAs: (v) => `/${v}/`,
})}
label={t("label.regex")}