Question:I’m new to Golang.
golang version: 1.17.8
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 use
divein 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
Userstruct to this:
If you have better answer, please add a comment about this, thank you!