David Parks
David Parks

Reputation: 32111

How to standardize and organize error messages with Hibernate Validator (running under Spring framework)

I'm learning Hibernate Validator. I see that I can add an error message text to any annotation.

But this seems like a bad way to handle error messages. It would be cleaner to return an error message ID and look up the message text in some resource file like a Properties file.

In this way I can later extend to other languages by swapping out the particular resource file; and the error messages are organized into one coherent location.

What's the best approach here with Hibernate Validator?

Upvotes: 0

Views: 2689

Answers (1)

Lefteris Laskaridis
Lefteris Laskaridis

Reputation: 2322

You might want to check this section in the manual for an approach of i18n error descriptions in Hibernate Validator.

There is another tutorial which might prove handy.

Cheers!

Upvotes: 2

Related Questions