∴ Vector: Centralize display name validation using Pydantic Annotated#592
∴ Vector: Centralize display name validation using Pydantic Annotated#592ToolchainLab wants to merge 1 commit into
Conversation
Extracted duplicated whitespace stripping and empty-string validation for display names into a reusable `DisplayNameStr` type using Pydantic V2's `Annotated` and `BeforeValidator`. Replaced repeated `@field_validator` methods across `RegisterRequest` and `PasskeyRegisterStartRequest`. Removed unused `_validate_display_name` function. Co-authored-by: ToolchainLab <263750431+ToolchainLab@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
display_namevalidation logic into a reusable Pydantic V2 type (DisplayNameStrusingAnnotatedandBeforeValidator). Replaced repeated@field_validatormethods inRegisterRequestandPasskeyRegisterStartRequest. Removed the unused_validate_display_namefunction.normalize_display_name) that safely handles types before stripping. Wrapped this in aBeforeValidatorwithin anAnnotatedtype to create a composable validation primitive that perfectly replaces the scattered classmethods.uv run --locked ruff format . && uv run --locked ruff check . && uv run --locked mypy src && uv run pytestensuring no behavior changes and that standard Pydantic validation errors still surface correctly for empty inputs.normalize_display_namecorrectly verifiesisinstance(v, str)before mutating, allowing non-string inputs to safely fall through to Pydantic's built-in type validation.@field_validatorimplementations, and standard test coverage confirms schemas correctly reject whitespace-only names.PR created automatically by Jules for task 9427188932183556861 started by @ToolchainLab