'Forbid extra keys in JSON validation

I have tried to forbid extra keys during struct validation in Golang, which is defined as -

type Test struct {
Test []*string `json:"test" validate:"required,min=1,max=10,unique"`
}

But the validation is not restricting the extra keys in the input JSON and it passes the validation, The method which I used was-

validationErr := validate.Struct(user).excludes(extra)

is there any other way by which we can forbid extra keys during validation?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source