dan-zx / zekke-api

Geographic web services for directions and POIs in private spaces
https://zekke.herokuapp.com
Apache License 2.0
0 stars 0 forks source link

Hibernate Validator default messages and custom interpolator strange behaviour #4

Open dan-zx opened 7 years ago

dan-zx commented 7 years ago

It seems that when a custom interpolator is defined in a new Validation bean. This custom interpolator is only working with messages that are not part of org.hibernate.validator.ValidationMessages

Looks like Spring has something to do with this because in BaseValidationTest. Hibernate Validator is loading both the user messages and also the default messages. When a default message is rewritten in the user messages, user messages takes priority. This behavior is way different in the actual application run.

dan-zx commented 7 years ago

Creating a spring bean with LocalValidatorFactoryBean and use ResourceBundleMessageSource to interpolate custom validation messages will translate correctly messages using the Accept-Language header but only for custom messages.

Default messages (hibernate validator) are not translated with this approach and always use the default locale.