Class GenericValidator
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisBlankOrNull(String value) Checks if the field isn't null and length of the field is greater than zero not including whitespace.static booleanChecks if the value can safely be converted to a byte primitive.static booleanChecks if the value can safely be converted to a double primitive.static booleanChecks if the value can safely be converted to a float primitive.static booleanisInRange(byte value, byte min, byte max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanisInRange(double value, double min, double max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanisInRange(float value, float min, float max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanisInRange(int value, int min, int max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanisInRange(long value, long min, long max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanisInRange(short value, short min, short max) Checks if a value is within a range (min & max specified in the vars attribute).static booleanChecks if the value can safely be converted to a int primitive.static booleanChecks if the value can safely be converted to a long primitive.static booleanChecks if the value can safely be converted to a short primitive.static booleanmatchRegexp(String value, String regexp) Checks if the value matches the regular expression.static booleanChecks if the value's length is less than or equal to the max.static booleanChecks if the value's adjusted length is less than or equal to the max.static booleanmaxValue(double value, double max) Checks if the value is less than or equal to the max.static booleanmaxValue(float value, float max) Checks if the value is less than or equal to the max.static booleanmaxValue(int value, int max) Checks if the value is less than or equal to the max.static booleanmaxValue(long value, long max) Checks if the value is less than or equal to the max.static booleanChecks if the value's length is greater than or equal to the min.static booleanChecks if the value's adjusted length is greater than or equal to the min.static booleanminValue(double value, double min) Checks if the value is greater than or equal to the min.static booleanminValue(float value, float min) Checks if the value is greater than or equal to the min.static booleanminValue(int value, int min) Checks if the value is greater than or equal to the min.static booleanminValue(long value, long min) Checks if the value is greater than or equal to the min.
-
Constructor Details
-
GenericValidator
public GenericValidator()
-
-
Method Details
-
isBlankOrNull
Checks if the field isn't null and length of the field is greater than zero not including whitespace.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if blank or null.
-
isByte
Checks if the value can safely be converted to a byte primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to a Byte.
-
isDouble
Checks if the value can safely be converted to a double primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to a Double.
-
isFloat
Checks if the value can safely be converted to a float primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to a Float.
-
isInRange
public static boolean isInRange(byte value, byte min, byte max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInRange
public static boolean isInRange(double value, double min, double max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInRange
public static boolean isInRange(float value, float min, float max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInRange
public static boolean isInRange(int value, int min, int max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInRange
public static boolean isInRange(long value, long min, long max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInRange
public static boolean isInRange(short value, short min, short max) Checks if a value is within a range (min & max specified in the vars attribute).
- Parameters:
value- The value validation is being performed on.min- The minimum value of the range.max- The maximum value of the range.- Returns:
- true if the value is in the specified range.
-
isInt
Checks if the value can safely be converted to a int primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to an Integer.
-
isLong
Checks if the value can safely be converted to a long primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to a Long.
-
isShort
Checks if the value can safely be converted to a short primitive.
- Parameters:
value- The value validation is being performed on.- Returns:
- true if the value can be converted to a Short.
-
matchRegexp
Checks if the value matches the regular expression.
- Parameters:
value- The value validation is being performed on.regexp- The regular expression.- Returns:
- true if matches the regular expression.
-
maxLength
Checks if the value's length is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum length.- Returns:
- true if the value's length is less than the specified maximum.
-
maxLength
Checks if the value's adjusted length is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum length.lineEndLength- The length to use for line endings.- Returns:
- true if the value's length is less than the specified maximum.
-
maxValue
public static boolean maxValue(double value, double max) Checks if the value is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum numeric value.- Returns:
- true if the value is <= the specified maximum.
-
maxValue
public static boolean maxValue(float value, float max) Checks if the value is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum numeric value.- Returns:
- true if the value is <= the specified maximum.
-
maxValue
public static boolean maxValue(int value, int max) Checks if the value is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum numeric value.- Returns:
- true if the value is <= the specified maximum.
-
maxValue
public static boolean maxValue(long value, long max) Checks if the value is less than or equal to the max.
- Parameters:
value- The value validation is being performed on.max- The maximum numeric value.- Returns:
- true if the value is <= the specified maximum.
-
minLength
Checks if the value's length is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum length.- Returns:
- true if the value's length is more than the specified minimum.
-
minLength
Checks if the value's adjusted length is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum length.lineEndLength- The length to use for line endings.- Returns:
- true if the value's length is more than the specified minimum.
-
minValue
public static boolean minValue(double value, double min) Checks if the value is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum numeric value.- Returns:
- true if the value is >= the specified minimum.
-
minValue
public static boolean minValue(float value, float min) Checks if the value is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum numeric value.- Returns:
- true if the value is >= the specified minimum.
-
minValue
public static boolean minValue(int value, int min) Checks if the value is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum numeric value.- Returns:
- true if the value is >= the specified minimum.
-
minValue
public static boolean minValue(long value, long min) Checks if the value is greater than or equal to the min.
- Parameters:
value- The value validation is being performed on.min- The minimum numeric value.- Returns:
- true if the value is >= the specified minimum.
-