结构体如下
Go
type CreateParams struct {
AId uint `json:"a_id" binding:"required,"
BId uint `json:"b_id" binding:"required,"
}
运行时报错:Invalid validation tag on field 'AId'
原因:在binding中,如果只有一个要求,不要加逗号,否则会逗号被当作一个词验证
修改:
Go
type CreateParams struct {
AId uint `json:"a_id" binding:"required"
BId uint `json:"b_id" binding:"required"
}