jwt method
Ensures that the string is a valid JSON Web Token (JWT).
This method adds an JwtValidator to check if the given string follows the standard JWT format.
A valid JWT consists of three base64-encoded sections separated by dots (.):
- Header
- Payload
- Signature
Example
final validator = v.string().jwt();
print(validator.validate("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvbiIsImlhdCI6MTUxNjIzOTAyMn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")); // true
print(validator.validate("invalid.jwt.token")); // false
print(validator.validate(null)); // false
Parameters
message: (optional) A custom validation message.
Returns
The current VString instance with the email validation applied.
Implementation
VString jwt({String? message}) {
return add(JwtValidator(message: message ?? _message.jwt));
}