Skip to content

Commit 3eaa469

Browse files
authored
fix: prevent validating empty inputs in poll forms (#2780)
1 parent a2805b0 commit 3eaa469

File tree

14 files changed

+26
-4
lines changed

14 files changed

+26
-4
lines changed

โ€Žsrc/components/Poll/PollActions/AddCommentForm.tsxโ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ export const AddCommentForm = ({ close, messageId }: AddCommentFormProps) => {
3434
type: 'text',
3535
value: ownAnswer?.answer_text ?? '',
3636
},
37+
validator: (value) => {
38+
const valueString = typeof value !== 'undefined' ? value.toString() : value;
39+
const trimmedValue = valueString?.trim();
40+
if (!trimmedValue) {
41+
return new Error(t('This field cannot be empty or contain only spaces'));
42+
}
43+
return;
44+
},
3745
},
3846
}}
3947
onSubmit={async (value) => {

โ€Žsrc/components/Poll/PollActions/SuggestPollOptionForm.tsxโ€Ž

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ export const SuggestPollOptionForm = ({
3838
value: '',
3939
},
4040
validator: (value) => {
41-
if (!value) return;
42-
const existingOption = options.find(
43-
(option) => option.text === (value as string).trim(),
44-
);
41+
const valueString = typeof value !== 'undefined' ? value.toString() : value;
42+
const trimmedValue = valueString?.trim();
43+
if (!trimmedValue) {
44+
return new Error(t('This field cannot be empty or contain only spaces'));
45+
}
46+
const existingOption = options.find((option) => option.text === trimmedValue);
4547
if (existingOption) {
4648
return new Error(t('Option already exists'));
4749
}

โ€Žsrc/i18n/de.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
"Submit": "Absenden",
142142
"Suggest an option": "Eine Option vorschlagen",
143143
"Thinking...": "Denken...",
144+
"This field cannot be empty or contain only spaces": "Dieses Feld darf nicht leer sein oder nur Leerzeichen enthalten",
144145
"This message did not meet our content guidelines": "Diese Nachricht entsprach nicht unseren Inhaltsrichtlinien",
145146
"This message was deleted...": "Diese Nachricht wurde gelรถscht...",
146147
"Thread": "Thread",

โ€Žsrc/i18n/en.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
"Submit": "Submit",
142142
"Suggest an option": "Suggest an option",
143143
"Thinking...": "Thinking...",
144+
"This field cannot be empty or contain only spaces": "This field cannot be empty or contain only spaces",
144145
"This message did not meet our content guidelines": "This message did not meet our content guidelines",
145146
"This message was deleted...": "This message was deleted...",
146147
"Thread": "Thread",

โ€Žsrc/i18n/es.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"Submit": "Enviar",
144144
"Suggest an option": "Sugerir una opciรณn",
145145
"Thinking...": "Pensando...",
146+
"This field cannot be empty or contain only spaces": "Este campo no puede estar vacรญo o contener solo espacios",
146147
"This message did not meet our content guidelines": "Este mensaje no cumple con nuestras directrices de contenido",
147148
"This message was deleted...": "Este mensaje fue eliminado...",
148149
"Thread": "Hilo",

โ€Žsrc/i18n/fr.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"Submit": "Envoyer",
144144
"Suggest an option": "Suggรฉrer une option",
145145
"Thinking...": "Rรฉflexion...",
146+
"This field cannot be empty or contain only spaces": "Ce champ ne peut pas รชtre vide ou contenir uniquement des espaces",
146147
"This message did not meet our content guidelines": "Ce message ne respecte pas nos directives de contenu",
147148
"This message was deleted...": "Ce message a รฉtรฉ supprimรฉ...",
148149
"Thread": "Fil de discussion",

โ€Žsrc/i18n/hi.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Submit": "เคœเคฎเคพ เค•เคฐเฅ‡เค‚",
143143
"Suggest an option": "เคเค• เคตเคฟเค•เคฒเฅเคช เคธเฅเคเคพเคต เคฆเฅ‡เค‚",
144144
"Thinking...": "เคธเฅ‹เคš เคฐเคนเคพ เคนเฅˆ...",
145+
"This field cannot be empty or contain only spaces": "เคฏเคน เคซเคผเฅ€เคฒเฅเคก เค–เคพเคฒเฅ€ เคจเคนเฅ€เค‚ เคนเฅ‹ เคธเค•เคคเคพ เคฏเคพ เค•เฅ‡เคตเคฒ เคฐเคฟเค•เฅเคค เคธเฅเคฅเคพเคจ เคจเคนเฅ€เค‚ เคฐเค– เคธเค•เคคเคพ",
145146
"This message did not meet our content guidelines": "เคฏเคน เคธเค‚เคฆเฅ‡เคถ เคนเคฎเคพเคฐเฅ‡ เคธเคพเคฎเค—เฅเคฐเฅ€ เคฆเคฟเคถเคพเคจเคฟเคฐเฅเคฆเฅ‡เคถเฅ‹เค‚ เค•เฅ‡ เค…เคจเฅเคฐเฅ‚เคช เคจเคนเฅ€เค‚ เคฅเคพ",
146147
"This message was deleted...": "เคฎเฅˆเคธเฅ‡เคœ เคนเคŸเคพ เคฆเคฟเคฏเคพ เค—เคฏเคพ",
147148
"Thread": "เคฐเคฟเคชเฅเคฒเคพเคˆ เคฅเฅเคฐเฅ‡เคก",

โ€Žsrc/i18n/it.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"Submit": "Invia",
144144
"Suggest an option": "Suggerisci un'opzione",
145145
"Thinking...": "Pensando...",
146+
"This field cannot be empty or contain only spaces": "Questo campo non puรฒ essere vuoto o contenere solo spazi",
146147
"This message did not meet our content guidelines": "Questo messaggio non soddisfa le nostre linee guida sui contenuti",
147148
"This message was deleted...": "Questo messaggio รจ stato cancellato...",
148149
"Thread": "Discussione",

โ€Žsrc/i18n/ja.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"Submit": "้€ไฟก",
140140
"Suggest an option": "ใ‚ชใƒ—ใ‚ทใƒงใƒณใ‚’ๆๆกˆ",
141141
"Thinking...": "่€ƒใˆไธญ...",
142+
"This field cannot be empty or contain only spaces": "ใ“ใฎใƒ•ใ‚ฃใƒผใƒซใƒ‰ใฏ็ฉบใซใ™ใ‚‹ใ“ใจใฏใงใใพใ›ใ‚“ใ€‚ใพใŸใ€็ฉบ็™ฝๆ–‡ๅญ—ใฎใฟใ‚’ๅซใ‚€ใ“ใจใ‚‚ใงใใพใ›ใ‚“",
142143
"This message did not meet our content guidelines": "ใ“ใฎใƒกใƒƒใ‚ปใƒผใ‚ธใฏใ‚ณใƒณใƒ†ใƒณใƒ„ใ‚ฌใ‚คใƒ‰ใƒฉใ‚คใƒณใซ้ฉๅˆใ—ใฆใ„ใพใ›ใ‚“",
143144
"This message was deleted...": "ใ“ใฎใƒกใƒƒใ‚ปใƒผใ‚ธใฏๅ‰Š้™คใ•ใ‚Œใพใ—ใŸ...",
144145
"Thread": "ใ‚นใƒฌใƒƒใƒ‰",

โ€Žsrc/i18n/ko.jsonโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
"Submit": "์ œ์ถœ",
140140
"Suggest an option": "์˜ต์…˜ ์ œ์•ˆ",
141141
"Thinking...": "์ƒ๊ฐ ์ค‘...",
142+
"This field cannot be empty or contain only spaces": "์ด ํ•„๋“œ๋Š” ๋น„์›Œ๋‘˜ ์ˆ˜ ์—†์œผ๋ฉฐ ๊ณต๋ฐฑ๋งŒ ํฌํ•จํ•  ์ˆ˜๋„ ์—†์Šต๋‹ˆ๋‹ค",
142143
"This message did not meet our content guidelines": "์ด ๋ฉ”์‹œ์ง€๋Š” ์ฝ˜ํ…์ธ  ๊ฐ€์ด๋“œ๋ผ์ธ์„ ์ถฉ์กฑํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.",
143144
"This message was deleted...": "์ด ๋ฉ”์‹œ์ง€๋Š” ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค...",
144145
"Thread": "์Šค๋ ˆ๋“œ",

0 commit comments

Comments
ย (0)