-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Hi,
I’ve stumbled over some strange behavior regarding internationalization of validation error messages in a spring-boot application using webflux. But I think the error is related to spring-framework and webflux.
When I’m validating fields in the request body, the language of occurring validation error messages can be changed via the Accept-Language HTTP header. This is done automatically because the AcceptHeaderLocaleContextResolver is used during the validation process.
Although when I’m validating a URL query parameter or a path variable (e.g. via the @Size validation annotation), the AcceptHeaderLocaleContextResolver is not used during the validation and the validation error message is always generated in the language of the JVM locale.
Is this the correct behavior?
I’v attached a small demo project.
In the DemoApplicationTests class there are the testBodyValidationErrorForLocaleEN and testBodyValidationErrorForLocaleDE methods which are passing without errors. The testPathVariableValidationErrorForLocaleEN
and testPathVariableValidationErrorForLocaleDE methods are not passing (or at least one of them regarding your JVM locale)
Tested Version:
Spring-boot: 3.3.5
(Which is using Spring-framework: 6.1.14)