From 43c1dbd945aef115adf842bfae9a4ff879cb7dbb Mon Sep 17 00:00:00 2001 From: Sam Lucidi Date: Wed, 6 Dec 2023 16:37:17 -0500 Subject: [PATCH] questionnaire validation should tolerate order 0 Signed-off-by: Sam Lucidi --- assessment/assessment.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assessment/assessment.go b/assessment/assessment.go index e49c75adc..a9e0f30e2 100644 --- a/assessment/assessment.go +++ b/assessment/assessment.go @@ -128,7 +128,7 @@ func (r *Assessment) Confidence() (score int) { // // Section represents a group of questions in a questionnaire. type Section struct { - Order uint `json:"order" yaml:"order" binding:"required"` + Order *uint `json:"order" yaml:"order" binding:"required"` Name string `json:"name" yaml:"name"` Questions []Question `json:"questions" yaml:"questions" binding:"dive"` Comment string `json:"comment,omitempty" yaml:"comment,omitempty"` @@ -179,11 +179,11 @@ func (r *Section) Tags() (tags []CategorizedTag) { // // Question represents a question in a questionnaire. type Question struct { - Order uint `json:"order" yaml:"order" binding:"required"` + Order *uint `json:"order" yaml:"order" binding:"required"` Text string `json:"text" yaml:"text"` Explanation string `json:"explanation" yaml:"explanation"` - IncludeFor []CategorizedTag `json:"includeFor,omitempty" yaml:"includeFor,omitempty" binding:"excluded_with=ExcludeFor"` - ExcludeFor []CategorizedTag `json:"excludeFor,omitempty" yaml:"excludeFor,omitempty" binding:"excluded_with=IncludeFor"` + IncludeFor []CategorizedTag `json:"includeFor,omitempty" yaml:"includeFor,omitempty"` + ExcludeFor []CategorizedTag `json:"excludeFor,omitempty" yaml:"excludeFor,omitempty"` Answers []Answer `json:"answers" yaml:"answers" binding:"dive"` } @@ -224,7 +224,7 @@ func (r *Question) Tags() (tags []CategorizedTag) { // // Answer represents an answer to a question in a questionnaire. type Answer struct { - Order uint `json:"order" yaml:"order" binding:"required"` + Order *uint `json:"order" yaml:"order" binding:"required"` Text string `json:"text" yaml:"text"` Risk string `json:"risk" yaml:"risk" binding:"oneof=red yellow green unknown"` Rationale string `json:"rationale" yaml:"rationale"`