I am performing testing on a functionality which requires following strcuture data to be sent as request's body while performing http request,
type ReqDataFormat struct {
File *multipart.FileHeader `form:"file" validate:"required" binding:"required"`
DivisionID int64 `form:"division_id" validate:"required" binding:"required"`
}
But the problem is when I try to unparse the incoming request's body into the ReqDataFormat struct var using c.ShouldBind
, it returns with the following error:
error="Key: 'ReqDataFormat.File' Error:Field validation for 'File' failed on the 'required' tag\nKey: 'ReqDataFormat.DivisionID' Error:Field validation for 'DivisionID' failed on the 'required' tag"
And if I remove the validate and binding tags from struct then it returns with empty struct fields with no data. Please suggest some solution.