diff --git a/api/questionnaire.go b/api/questionnaire.go index ff25a92c1..c7f69935c 100644 --- a/api/questionnaire.go +++ b/api/questionnaire.go @@ -193,7 +193,7 @@ type Questionnaire struct { Name string `json:"name" yaml:"name" binding:"required"` Description string `json:"description" yaml:"description"` Required bool `json:"required" yaml:"required"` - Sections []assessment.Section `json:"sections" yaml:"sections" binding:"required,dive"` + Sections []assessment.Section `json:"sections" yaml:"sections" binding:"required,min=1,dive"` Thresholds assessment.Thresholds `json:"thresholds" yaml:"thresholds" binding:"required"` RiskMessages assessment.RiskMessages `json:"riskMessages" yaml:"riskMessages" binding:"required"` Builtin bool `json:"builtin,omitempty" yaml:"builtin,omitempty"` diff --git a/assessment/assessment.go b/assessment/assessment.go index a9e0f30e2..43fdef1d6 100644 --- a/assessment/assessment.go +++ b/assessment/assessment.go @@ -130,7 +130,7 @@ func (r *Assessment) Confidence() (score int) { type Section struct { Order *uint `json:"order" yaml:"order" binding:"required"` Name string `json:"name" yaml:"name"` - Questions []Question `json:"questions" yaml:"questions" binding:"dive"` + Questions []Question `json:"questions" yaml:"questions" binding:"min=1,dive"` Comment string `json:"comment,omitempty" yaml:"comment,omitempty"` } @@ -184,7 +184,7 @@ type Question struct { Explanation string `json:"explanation" yaml:"explanation"` IncludeFor []CategorizedTag `json:"includeFor,omitempty" yaml:"includeFor,omitempty"` ExcludeFor []CategorizedTag `json:"excludeFor,omitempty" yaml:"excludeFor,omitempty"` - Answers []Answer `json:"answers" yaml:"answers" binding:"dive"` + Answers []Answer `json:"answers" yaml:"answers" binding:"min=1,dive"` } //