mirror of
https://github.com/hexastack/hexabot
synced 2025-01-23 02:47:56 +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" ? (
|
{typeof value === "string" && patternType === "regex" ? (
|
||||||
<RegexInput
|
<RegexInput
|
||||||
{...registerInput(t("message.regex_is_invalid"), idx, {
|
{...registerInput(t("message.regex_is_invalid"), idx, {
|
||||||
validate: (value) =>
|
validate: (pattern) => {
|
||||||
(value.trim() !== "" && value !== "/") ??
|
try {
|
||||||
t("message.regex_is_invalid"),
|
if (typeof pattern === "string")
|
||||||
|
new RegExp(pattern.slice(1, -1));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (_e) {
|
||||||
|
return t("message.regex_is_invalid");
|
||||||
|
}
|
||||||
|
},
|
||||||
setValueAs: (v) => `/${v}/`,
|
setValueAs: (v) => `/${v}/`,
|
||||||
})}
|
})}
|
||||||
label={t("label.regex")}
|
label={t("label.regex")}
|
||||||
|
Loading…
Reference in New Issue
Block a user