Search code examples
hibernate-validator

Constraints configuring for Beans Validation via a properties file


I'd like to configure bean validation (JEE6) constraints via a properties file or database.

So for instance the Max value below would get pulled from the properties file or database. Is this possible in ?

@Max(value = 1) private int elvis;

Any suggestions on a possible approach.


Solution

  • It is not possible via standard Bean Validation. The default as per specification are annotations or as alternative XML.

    In theory, Hibernate Validator has the (internal) concept of a MetaDataProvider and one could think of plugging in a DbMetaDataProvider. However, that would be quite some work and I am not sure that it would be worth the effort.

    What is you use case anyways? Why don't you use XML?