1 16 17 package info.jtrac.util; 18 19 import org.springframework.validation.Errors; 20 import org.springframework.webflow.execution.RequestContext; 21 22 27 public class ValidationUtils { 28 29 public static final String ERROR_EMPTY_CODE = "error.empty"; 30 public static final String ERROR_EMPTY_MSG = "Value Required"; 31 32 public static void rejectIfEmpty(Errors errors, String ... names) { 33 for (String name : names) { 34 org.springframework.validation.ValidationUtils.rejectIfEmpty(errors, name, ERROR_EMPTY_CODE); 35 } 36 } 37 38 public static String getParameter(RequestContext context, String name) { 39 String value = (String ) context.getRequestParameters().get(name); 40 if (value == null || value.trim().equals("")) { 41 return null; 42 } 43 return value.trim(); 44 } 45 46 public static boolean isAllUpperCase(String input) { 47 if (input == null) { 48 return false; 49 } 50 return input.matches("[A-Z0-9]+"); 51 } 52 53 public static boolean isAllLowerCase(String input) { 54 if (input == null) { 55 return false; 56 } 57 return input.matches("[a-z0-9]+"); 58 } 59 60 64 public static boolean isCamelDashCase(String input) { 65 if (input == null) { 66 return false; 67 } 68 return input.matches("[A-Z][a-z]+(-[A-Z][a-z]+)*"); 69 } 70 71 72 } 73 | Popular Tags |