@ SuppressWarnings ( "unchecked" ) private static ValidationFail performFieldValidations ( Context context , FieldInfo fieldInfo , View view ) { // first, we need to check if condition is not applied for all validations on field if ( fieldInfo . condition != null && fieldInfo . condition . validationAnnotation ( ) . equals ( Condition . class ) ) { // condition is applied to all validations on field boolean evaluation = evaluateCondition ( view , fieldInfo . condition ) ; if ( ! evaluation ) { // go to next field return null ; } } // field validations for ( ValidationInfo valInfo : fieldInfo . validationInfoList ) { final Annotation annotation = valInfo . annotation ; if ( fieldInfo . condition != null && fieldInfo . condition . validationAnnotation ( ) . equals ( annotation . annotationType ( ) ) ) { boolean evaluation = evaluateCondition ( view , fieldInfo . condition ) ; if ( ! evaluation ) { // continue to next annotation continue ; } } final IFieldAdapter adapter = FieldAdapterFactory . getAdapterForField ( view , annotation ) ; if ( adapter == null ) { throw new NoFieldAdapterException ( view , annotation ) ; } final Object value = adapter . getFieldValue ( annotation , view ) ; final boolean isValid = valInfo . validator . validate ( annotation , value ) ; if ( ! isValid ) { final String message = valInfo . validator . getMessage ( context , annotation , value ) ; final int order = valInfo . validator . getOrder ( annotation ) ; // no more validations on this field return new ValidationFail ( view , message , order ) ; } } return null ; }
perform all validations on single field