Skip to content

Commit f60c527

Browse files
committed
Add validation for empty options in Voting Form
Added an additional validation check in the Voting form component to prevent users from submitting empty options. If the options are empty, the function will now early return, effectively halting the submission process.
1 parent 0c63410 commit f60c527

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/Voting/Form.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ onSetup((post) => {
1515
// Remove options that have not been filled in
1616
options.value = options.value.filter((option) => option.poll !== undefined)
1717
18+
if (options.value.length === 0) {
19+
return post
20+
}
21+
1822
const poll: Poll = {
1923
options: options.value.map((option) => {
2024
return {

0 commit comments

Comments
 (0)