Question:
I’m new to Golang.golang version: 1.17.8
validator: “github.com/go-playground/validator/v10“
I want to validate an incoming JSON payload after loaded into nested struct data structure. Here’s my incoming JSON payload,
Answer:
According to the documentation of the validator package, you can usedive
in your struct tag to get this behavior. This causes the validator to also validate the nested struct/slice/etc.So you would need to update your
User
struct to this:If you have better answer, please add a comment about this, thank you!