Using the fluent API in a JavaEE environment

Description

I want to set some constraints programmatically using the fluent API, because they depend on the case for example a min and max of a
@Size constraint could vary or a field could be @NotNull or not...

But I can't use the fluent API in a JavaEE environment to configured programmatically the Validator or ValidatorFactory WildFly is providing to JSF or JPA (more info on this post: http://stackoverflow.com/questions/27970745/hibernate-validator-programmatic-constraints-declaration-and-jsf)

The configuration of constraints could vary among the users of the app, so the configuration of Validator/ValidatorFactory should depends on a scope @SessionScoped at least and maybe @ApplicationScoped

configured constraints programmatically at the application scope could allow managers of the application to change constraints with a web interface without changing the code of the application and even without restart the application (constraints could be saved in a database)

configured constraints programmatically at the session scope could allow users to have differents constraints according to what there are doing. Ex: In an application who managed calls of projects, the constraints could depend on the call of project, so according to the call of project a user could have a specific set of constraints to applied, while others users, in the same time, could have others sets of constraints.

In both case the programmatic configuration could rely on injection, the "configurator" could have an injected (@Inject) EJB to access a database, in the case of a session scoped configuration @SessionScoped EJB could be injected to provide informations about the state of the session

So it's an improvement to integrate the fluent API in JavaEE environment in general or at least in WildFly

IMHO The fluent API is really a good idea and shoul be part of the Bean Validation spec...

Thank you for your work

Environment

WildFly 8.2 application server Hibernate validator 5.1.3

Activity

Show:

Gunnar Morling February 19, 2015 at 12:11 PM

Gunnar Morling February 18, 2015 at 7:04 PM

Hey , I'll give this a look, so we can get it into the next release. Unless you have something working already?

Gunnar Morling February 9, 2015 at 9:09 AM

Hi , how is it going with this one? Anything we can help you with?

Gunnar Morling January 22, 2015 at 2:48 PM
Edited

That's great, !

You can find out some general hints on getting started with working on Hibernate Validator in the contribution guide. For the topic at hand you might check in the code base how the "fail fast" property is handled which is another HV-specific setting which can be given either via the API (HibernateValidatorConfiguration) or XML (property "hibernate.validator.fail_fast"). Programmatically defined constraint mappings are represented by (Default)ConstraintMapping.

Cédric C January 22, 2015 at 2:33 PM

Yes https://hibernate.atlassian.net/browse/HV-918#icft=HV-918 is a very close subject
I have no idea how to do it, but I could try!

Fixed

Details

Assignee

Reporter

Labels

Participants

Cédric C
Gunnar Morling

Fix versions

Affects versions

Priority

Created January 21, 2015 at 1:11 PM
Updated July 15, 2015 at 12:12 PM
Resolved February 19, 2015 at 7:58 PM

Flag notifications