-
Dec 12th, 2010, 04:12 PM
#1
Validate object fields that are not form fields with JSR-303 @Valid and annotations?
Hibernate's validator is my JSR-303 provider in my Spring MVC application. When I use @Valid, and then use the JSR-303 annotations on the form object fields, it validates just fine. However, there are some instances where I want to validate object fields that do not map one-to-one with jsp input fields. For example, I have a registration form with password and re-enter password input fields. The validation constraint should be @AssertTrue on a boolean object field that looks to see if password and re-enter password match. Hibernate's documentation shows that this is possible, but you have to invoke the validator manually, which defeats the purpose of my current approach with Spring annotations. Is there a way to do this in Spring without invoking the Hibernate validator?
-
Dec 12th, 2010, 09:49 PM
#2
I just found this:
http://forum.springsource.org/showthread.php?t=84913
Which links to this:
https://jira.springframework.org/browse/SPR-6437
Unless someone can provide some further clarification, it appears that when using @Valid, it is not possible to bind additional data (that did not come from an html form element) to the form object for validation. You would still have to create a custom validator and call it.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules