public static Constraint anyPassed ( Constraint ... constraints ) { return ( ( name , data , messages , options ) -> { logger . debug ( "checking any passed for {}" , name ) ; List < Map . Entry < String , String > > errErrors = new ArrayList <> ( ) ; for ( Constraint constraint : constraints ) { List < Map . Entry < String , String > > errors = constraint . apply ( name , data , messages , options ) ; if ( errors . isEmpty ( ) ) return Collections . emptyList ( ) ; else { errErrors . addAll ( errors ) ; } } String label = getLabel ( name , messages , options ) ; String errStr = errErrors . stream ( ) . map ( e -> e . getValue ( ) ) . collect ( Collectors . joining ( ", " , "[" , "]" ) ) ; return Arrays . asList ( entry ( name , String . format ( messages . get ( "error.anypassed" ) , label , errStr ) ) ) ; } ) ; }
make a compound Constraint which checks whether any inputting constraints passed