mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 18:45:57 +00:00
Merge pull request #252 from Hexastack/fix/form-block-trigger-regex-check-format
fix(frontend): regex input control
This commit is contained in:
commit
b2c32fe27d
@ -266,9 +266,20 @@ 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 (
|
||||||
|
pattern.at(0) === "/" &&
|
||||||
|
pattern.at(-1) === "/" &&
|
||||||
|
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