How to implement group validator?
How to implement group validator?
I have the following structure
type User struct {
UserId int64 `binding:"required,number"`
Name string `json:"name" form:"name" binding:"gte=3"`
}
Now I need to implement findUserById , I have to verify the ID exist, so i use required. But when I implement saveUser, I have to verify that the ID doesn't exist because my database is a self-increment ID. They have a conflict

In Java spring boot, they can be distinguished by a custom group
The honest answer would be to break your Find + Save User struct up into two separate ones. I highly recommend doing this regardless otherwise you'll eventually end up with abstraction leakage between the two use case resulting in less maintainable and more brittle code.
I can't see adding this sort of grouping functionality support.
Hope this helps answer the question.