FroMage wrote:
We have issues with InvalidConstraint though because once we validate           
our persistent entities, we have a hard time mapping validation errors          
to UI fields.                                                                   
To be clearer: suppose we have a "name" bean property which fails               
validation, we want to put an error message in the UI next to our "name"        
input field. We may be able to gather the name of the bean property from        
the InvalidConstraint.getPropertyPath() but it's a field which requires         
parsing in order to get information.                                            
I suspect some kind of EL engine can access the field for you. Generally speaking, some ui framework would probably like to add some sort of indirection between a property name and a field name (depending on the philosophy). 
Quote:
                                                                                
Now suppose we have decided to put bean class validation methods in the         
bean itself, with several methods annotated with @AssertTrue. For those         
validation errors we would like to be able to specify that the                  
validation is the entire bean, not just the property annotated with             
@AssertTrue (which is just a placeholder for validation, not for a              
value).
Why did you do that (as opposed to a class level constraint?           
Others have requested to be able to ahve multiple fields per constraint failure, this mught help in your case.                                                                                                                                              
Quote:
I think InvalidConstraint should include more information about the             
error. Putting the validation metadata (the validation annotation which         
caused the error) as well as the property type (field, method, class)           
would certainly be useful. The InvalidConstraint.getPropertyPath()              
should be defined in a way which does not require parsing.                      
How should it be? I would welcome type safety.
Keep in mind that Incalidconstraint will probably need to be serializable, this limit what you want / can add.
Quote:
                                                                                
For instance if getPropertyPath() would return "field1.field2" we should        
be able to query the validation annotations (or constraints) that failed        
on "field2", and whether "field1" is a method or a field, same for              
field2.  
                                                                       What is the use case you have in mind?                                                                                
If we have that we can also differenciate validations cases such as:            
Quote:
                                                                                
class Foo{                                                                      
 @NotNull                                                                       
 Bar bar;                                                                       
}                                                                               
                                                                                
@MyValidator                                                                    
class Bar{                                                                      
}                                                                               
                                                                                
Where both a "NotNull" and "MyValidator" validation errors would be             
reported with property path "bar" I think.                                      
                                                                                
Thanks.
They both are differenciated as they do not come from the same object root. the uniqueness comes from the tuple propertypath / root object.
As you cna see, I am interested in the use cases that lead to your requests.