mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: add validation for fallback message requirement in OptionsForm
This commit is contained in:
parent
16377be405
commit
e2379324b2
@ -106,6 +106,7 @@
|
||||
"invalid_carousel_limit": "List limit must be >=1 and <= 10",
|
||||
"no_content_type": "No content type available, please create one first",
|
||||
"invalid_max_fallback_attempt_limit": "Max fallback attempt limit must have positive value",
|
||||
"fallback_message_required": "Fallback message is required",
|
||||
"regex_is_invalid": "Regex is invalid",
|
||||
"regex_is_empty": "Regex cannot be empty",
|
||||
"attachment_not_found": "Attachment is not found",
|
||||
|
@ -106,6 +106,7 @@
|
||||
"invalid_carousel_limit": "La limite doit être >=1 et <= 10",
|
||||
"no_content_type": "Il n'y a aucun type de contenu pour le moment, veuillez en ajouter un.",
|
||||
"invalid_max_fallback_attempt_limit": "La limite des tentatives de secours doit être un nombre positif.",
|
||||
"fallback_message_required": "Le message de secours est requis",
|
||||
"regex_is_invalid": "Le regex est invalide",
|
||||
"regex_is_empty": "Le regex ne peut pas être vide",
|
||||
"attachment_not_found": "La pièce jointe est introuvable",
|
||||
|
@ -104,6 +104,21 @@ export const OptionsForm = () => {
|
||||
name="options.fallback"
|
||||
control={control}
|
||||
defaultValue={block?.options?.fallback}
|
||||
rules={{
|
||||
validate: (value) => {
|
||||
if (!value) return true;
|
||||
if (value.max_attempts > 0) {
|
||||
if (
|
||||
!value.message ||
|
||||
value.message.every((msg) => !msg.trim())
|
||||
) {
|
||||
return t("message.fallback_message_required");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}}
|
||||
render={({ field }) => (
|
||||
<LocalFallbackInput
|
||||
value={field?.value}
|
||||
|
@ -95,6 +95,8 @@ const LocalFallbackInput: FC<LocalFallbackProps> = ({ value, onChange }) => {
|
||||
multiline={true}
|
||||
minInput={1}
|
||||
minRows={3}
|
||||
error={!!errors.options?.fallback}
|
||||
helperText={errors.options?.fallback?.message as string}
|
||||
onChange={(message) => {
|
||||
setFallback({
|
||||
...fallback,
|
||||
|
Loading…
Reference in New Issue
Block a user