feat(api): zod schema error messages → i18n catalog keys #212
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol#212
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
ADR-0025 §6 explicitly defers translating zod schema validator messages. Today the
lib/dto/auth.ts/lib/dto/user.tszod refinements still carry English strings inline ("A valid email is required.","Password must be at least N characters."). The API-code → catalog-key indirection (LOGIN_ERROR_KEYS,REGISTER_ERROR_KEYS) routes top-level error codes through the catalog, but per-field zod issues still surface English regardless ofAccept-Language.Source
zodErrorMap-based helper that maps the short, finite set ofZodIssueCodes to catalog keys."apps/api/lib/dto/auth.tslines 53-56 names this as the deferred follow-up.Scope
zodErrorMap-based helper inapps/api/lib/api/that mapsZodIssueCode→ catalog key.zRegisterRequest,zLoginRequest) so per-field validation errors in theerrors[]array of Problem Details responses carry catalog keys instead of English strings.apps/client/) and@carol/api-clientto render those keys viareact-i18next— the existing top-level code path (errors.${LOGIN_ERROR_KEYS[code]}) is the shape to mirror.zNoteCreate,zNoteUpdate,zSkillCreate, etc. as a sweep across all DTOs that carry user-facing inline error strings.Acceptance criteria
apps/api/lib/api/zodErrorMap.tsexposes a helper that mapsZodIssueCode(and per-issue context likeparams.minimum) to a{ key, args }shape.messages/en.jsongains the catalog keys (e.g.errors.zod.invalidEmail,errors.zod.tooShort).errors[]array whose entries carry the new keys, not English strings.Out of scope
LOGIN_ERROR_KEYS/REGISTER_ERROR_KEYS(those already work; this ticket addresses the per-field gap only).Composes with
packages/i18n/