go version:1.18
request params
{
"questions_batch_id": "1",
"answer_list": [
{
"questions_ids": "1",
"answer": [
"2222","3333"
]
}
]
}
validate code:
type Answer struct {
QuestionsID string `json:"questions_id" binding:"required"`
Answer []string `json:"answer" binding:"required"`
}
type AnswerQuestionParams struct {
QuestionBatchId string `json:"questions_batch_id" binding:"required"`
AnswerList []*Answer `json:"answer_list" binding:"required"`
UserId string `json:"user_id" binding:"-"`
UserType string `json:"user_type" binding:"-"`
}
I was used required,dive
got an error :reflect: call of reflect.Value.Interface on zero Value
I hope when the questions_id in the answer_list does not exist, the verification fails