1 23 24 package org.infoglue.cms.util.validators; 25 26 40 public class ValidatorFactory { 41 46 49 private ValidatorFactory() {} 50 51 52 53 55 58 public static final StringValidator createStringValidator(String fieldName, boolean isRequired, int upperLengthLimit) { 59 return new StringValidator(fieldName, isRequired, upperLengthLimit); 60 } 61 62 65 public static final StringValidator createStringValidator(String fieldName, boolean isRequired, int lowerLengthLimit, int upperLengthLimit) { 66 return new StringValidator(fieldName, isRequired, lowerLengthLimit, upperLengthLimit); 67 } 68 69 public static final StringValidator createStringValidator(String fieldName,boolean isRequired, int lowerLengthLimit, int upperLengthLimit,boolean mustBeUnique,Class objectClass, Integer excludeId, Object excludedObject) { 70 return new StringValidator(fieldName, isRequired, lowerLengthLimit, upperLengthLimit, mustBeUnique, objectClass, excludeId, excludedObject); 71 } 72 73 public static final StringValidator createStringValidator(String fieldName,boolean isRequired,boolean mustBeUnique,Class objectClass, Integer excludeId, Object excludedObject) { 74 return new StringValidator(fieldName, isRequired, mustBeUnique, objectClass, excludeId, excludedObject); 75 } 76 77 78 81 public static final EmailValidator createEmailValidator(String fieldName, boolean isRequired, int upperLengthLimit) { 82 return new EmailValidator(fieldName, isRequired, upperLengthLimit); 83 } 84 85 88 public static final IntegerValidator createNonNegativeIntegerValidator(String fieldName, boolean isRequired) { 89 return new IntegerValidator(fieldName, isRequired, 0, Integer.MAX_VALUE); 90 } 91 92 95 public static final FloatValidator createNonNegativeFloatValidator(String fieldName, boolean isRequired) { 96 return new FloatValidator(fieldName, isRequired, new Float (0.0).floatValue(), Float.MAX_VALUE); 97 } 98 99 100 101 } | Popular Tags |