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

StackOverflow https://stackoverflow.com/questions/4124764

  •  29-09-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top