govalidator
govalidator copied to clipboard
Add IsJWT validation function, tests, and README entry (Fixes #502)
| Q | A |
|---|---|
| Documentation | yes |
| Bugfix | no |
| BC Break | no |
| New Feature | yes |
| RFC | yes |
| QA | yes |
Description
This PR adds a new validator function IsJWT() to the govalidator package.
Why this change is necessary:
Currently, JWT strings can only be validated using a manual regex inside a valid:"matches(...)" struct tag, which is not very convenient or readable. As per RFC-7519, a JWT is represented as a sequence of three URL-safe base64-encoded strings separated by periods ('.'). This PR implements a native validation function to improve developer ergonomics and code readability.
What this PR does:
- Implements a new
IsJWT()function using a compiled regex pattern. - Adds corresponding unit tests in
validator_test.go. - Updates the
README.mdfunction list to include the newIsJWT()function.
Target branch: master