mirror of https://github.com/golang-jwt/jwt.git
Add explicit ClaimsValidator implementation check for custom claims (#343)
* Add explicit ClaimsValidator implementation check for custom claims Prevent user from misnaming or fat fingering the Validate() method implementation. * Update example_test.go --------- Co-authored-by: Christian Banse <oxisto@aybaze.com>
This commit is contained in:
parent
1e76606719
commit
c80de55abe
|
@ -124,6 +124,9 @@ type MyCustomClaims struct {
|
|||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
// Ensure we implement [jwt.ClaimsValidator] at compile time so we know our custom Validate method is used.
|
||||
var _ jwt.ClaimsValidator = (*MyCustomClaims)(nil)
|
||||
|
||||
// Validate can be used to execute additional application-specific claims
|
||||
// validation.
|
||||
func (m MyCustomClaims) Validate() error {
|
||||
|
|
Loading…
Reference in New Issue