View Javadoc

1   package org.kuali.student.common.ui.client.validator;
2   
3   import java.util.List;
4   
5   import org.kuali.student.common.validation.dto.ValidationResultInfo;
6   import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel;
7   
8   public class ValidatorClientUtils {
9   
10  	/**
11  	 * Inspect the validation result to determine if there are any errors.
12   
13  	 * 
14  	 * @param validationResults
15  	 * @return true if at least one validation result is an error. 
16  	 */
17  	public static boolean hasErrors(List<ValidationResultInfo> validationResults){
18  		if (validationResults !=null){
19  			for (ValidationResultInfo vr:validationResults){
20  				if (vr.getErrorLevel() == ErrorLevel.ERROR){
21  					return true;
22  				}
23  			}
24  		}
25  		
26  		return false;
27  	}
28  
29  	/**
30  	 * Inspect the validation result to determine if there are any errors.
31  	 * 
32  	 * @param validationResults
33  	 * @return true if at least one validation result is an error. 
34  	 */
35  	public static boolean hasWarnings(List<ValidationResultInfo> validationResults){
36  		if (validationResults !=null){
37  			for (ValidationResultInfo vr:validationResults){
38  				if (vr.getErrorLevel() == ErrorLevel.WARN){
39  					return true;
40  				}
41  			}
42  		}
43  		
44  		return false;
45  	}
46  
47  }