(v: str)
| 4 | |
| 5 | |
| 6 | def validate_jwt_format(v: str) -> str: |
| 7 | jwt_pattern = r"^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$" |
| 8 | |
| 9 | if not re.match(jwt_pattern, v): |
| 10 | raise ValueError("Invalid JWT format. Expected format: header.payload.signature") |
| 11 | |
| 12 | parts = v.split(".") |
| 13 | if len(parts) != 3: |
| 14 | raise ValueError("JWT must have exactly 3 parts separated by dots") |
| 15 | |
| 16 | for i, part in enumerate(parts): |
| 17 | if not part: |
| 18 | raise ValueError(f"JWT part {i + 1} is empty") |
| 19 | |
| 20 | return v |
| 21 | |
| 22 | |
| 23 | JWTToken = Annotated[str, BeforeValidator(validate_jwt_format)] |
nothing calls this directly
no outgoing calls
no test coverage detected