mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 18:45:57 +00:00
fix(frontend): regex input control
This commit is contained in:
parent
95f45b75ef
commit
c4a1c16b94
@ -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")}
|
||||
|
Loading…
Reference in New Issue
Block a user