Skip to content

Commit 5a9b9c2

Browse files
committed
fix: add validation method and error message handling in QuestionDropdown
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent a138698 commit 5a9b9c2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/Questions/QuestionDropdown.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
:warningInvalid="answerType.warningInvalid"
1111
:contentValid="contentValid"
1212
:shiftDragHandle="shiftDragHandle"
13+
:errorMessage="errorMessage"
1314
v-on="commonListeners">
1415
<template #actions>
1516
<NcActionCheckbox
@@ -184,6 +185,16 @@ export default {
184185
},
185186
186187
methods: {
188+
async validate() {
189+
if (this.isRequired && this.values.length === 0) {
190+
this.errorMessage = t('forms', 'You must answer this question')
191+
return false
192+
}
193+
194+
this.errorMessage = null
195+
return true
196+
},
197+
187198
onDragStart() {
188199
this.isDragging = true
189200
},

0 commit comments

Comments
 (0)