What's the preferred approach for validating that at least one of fieldA, fieldB, or fieldC is valid using a Spring 3 validator? In othe开发者_StackOverflowr words, any 2 of the fields can be invalid, as long as the third is not.
This thread poses almost the same question. The solution there is to add the following to validation-rules.xml:
<validator name="requiredif" 
    classname="org.springmodules.validation.commons.Fi eldChecks"
    method="validateRequiredIf" 
    methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.springframework.validation.Errors, org.apache.commons.validator.Validator"
    msg="errors.required">
</validator> 
I use JSR-303 Bean Validation (see example here). Simply annotate the fields that you need to validate.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论