Is it possible for Spring's JSR-303 implementation to validate object fields that are not from form input?

StackOverflow https://stackoverflow.com/questions/4424338

سؤال

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?

هل كانت مفيدة؟
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top