Skip to content

feat: validation-error i18n contract (deferred-translation)#11

Merged
michaelmeneses merged 11 commits into
mainfrom
develop
Jun 4, 2026
Merged

feat: validation-error i18n contract (deferred-translation)#11
michaelmeneses merged 11 commits into
mainfrom
develop

Conversation

@michaelmeneses

Copy link
Copy Markdown
Contributor

Summary

Deferred-translation contract for validation errors.

MiddagValidationException::errors() now carries a framework-owned TranslatableMessage ({key, domain, params, defaultMessage}, mirroring Symfony's TranslatableMessage + a Spring-style defaultMessage). HttpKernel resolves each error at the response boundary to the wire shape {message, key, domain, params} (RFC 9457 / Symfony ConstraintViolationListNormalizer aligned): message is resolved through the bound host translator, falling back to English. Hosts (Moodle get_string, WordPress __) and React/Inertia clients localise via key/params; standalone is English by default.

Also fixes a bug: DtoHydrator no longer hardcodes 'This value is not valid.' for denormalization errors — it routes through the translator with a stable key.

New

TranslatableMessage, ViolationKeyMap, ValidationErrorBag, ValidationErrorSerializer. Validation no longer translates in-request; the kernel is the single resolution boundary.

Breaking

MiddagValidationException::errors() values and the 422 errors[field] payload change from string|string[] to {message, key, domain, params} (a list when a field has several errors). Raw-string errors still pass through unchanged. Pre-1.0 → minor (0.11.0).

Gate

composer check (PHPStan L6 + PHP-CS-Fixer + Rector) + composer test (545 tests) green; CI green on PHP 8.2 / 8.3 / 8.4.

@michaelmeneses michaelmeneses merged commit cf6dcd0 into main Jun 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant