[
http://opensource.atlassian.com/projects/hibernate/browse/HV-274?page=com...
]
Gunnar Morling commented on HV-274:
-----------------------------------
Just read my way through the comments. Some additions:
Better (type-safe) support for built-in or HV constraints is great, but I think we should
focus on the generic approach first as it is needed anyways for custom constraints and the
built-in/HV support could be added later.
bq. What bothers me in this model is that I am forced to either:
bq. * define a message even when I want the default
bq. * or if you have multiple with, you have to know the API designer's choice on
putting message before payload
Ack. I Think the user shouldn't be forced to invoke the methods in a certain order,
especially as there is no real need for this and it makes things harder to understand.
I also thought about an approach similar to mocking libraries:
{code:java}
Size size = createConstraint(Size.class);
init(size.min(), 7);
init(size.message(), "Custom message");
config
.type( ShoppingCart.class )
.onField("items")
.addConstraint( size );
{code}
I'm not sure whether I really like it :-), but it has some advantages:
* nearly same level of type-safety as when specifying actual annotations
* same handling of built-in and custom types
* same handling of payload/message/groups and custom annotation attributes
Disadvantages OTOH:
* uncommon style for non-testing API
* not fluent
Write a programmatic mapping API for constraint declarations
------------------------------------------------------------
Key: HV-274
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-274
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Affects Versions: 4.0.2.GA
Reporter: Emmanuel Bernard
Assignee: Hardy Ferentschik
Fix For: 4.1.0
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira