I have read the most recent documentation and I was curious how to tell Hibernate Validator to return the error on a field even though it is a class constraint. Take this for example:
Code:
@UniqueResumeSkill( message = "{resumeSkill.unique}" )
public class ResumeSkill extends DomainObject {
/* Fields */
@NotNull( message = "{resumeSkill.resume.notNull}" )
private Resume resume;
@NotNull( message = "{resumeSkill.skill.notNull}" )
private Skill skill;
private String years;
....
}
I'd really love it if that @UniqueResumeSkill constraint could actually report as an error on the "skill" field/property. I really have no clue how to tell Hibernate Validator to do that. I thought other people may be curious how to do this too, as this is a pretty common problem that happens frequently.
The reason is that Spring really depends on bean property paths, and while with a bit of effort it is possible to dig for the class-level constraint in the Spring errors object, I'd rather just point it to the skill field/property. Semantically, that's really where the error is in this case. They need would need to select a different Skill from the drop down box, so it makes sense to put the error here than at the class/form level.
Does Hibernate Validator have this capability yet? Do you think it may in the future if it doesn't already? Any notable workarounds? :)
Thanks!