|
|
|
I want to set some constrainst programmaticaly constraints programmatically using the fluent API, because they depends 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
|
|
|
|