Search code examples
javabean-validationhibernate-validator

Hibernate Validator 3.1.0.GA ignoring ValidationMessages.properties (test project included)


I have a problem with Hibernate Validator 3.1.0.GA not looking up custom validation messages in the property file ValidationMessages.properties.

To illustrate the problem, I created a small example project, which you can get through git:

git clone https://bitbucket.org/sstein/validation-example.git

After you got the source tree, you can test the problem by running the unit tests I created using:

mvn test

There are 3 test cases and validateDescriptionTest(com.example.MyClassTest) is failing with:

expected:<[Description must be between 1 and 10 characters long.]> but was:<[{descriptionMsg}]>

I also added a test case verifying that the resource bundle is accessible by unit tests and this works.

Does anyone know why this one is failing?

PS: I completely rewrote my initial question adding the example so that you can try on your own.


Solution

  • So the solution is simple and was found by Hardy Ferentschik of Hibernate:

    In Hibernate Validator 3.1.0.GA, the bundle must be called ValidatorMessages.properties and NOT ValidationMessages.properties.