Package org.europa.together.utils
Class Validator
- java.lang.Object
-
- org.europa.together.utils.Validator
-
public final class Validator extends Object
A simple RexEx Validator.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ASCII_CHARACTER
Printable ASCII Character: a-z A-Z.static String
BOOLEAN
Boolean.static String
DIGIT
Digits form 0-9.static String
E_MAIL_ADDRESS
Test if a Email Address in the typical format, like:
_a-zA-Z0-9-(.)_a-zA-Z0-9-(@)[a-zA-Z0-9-]*(.)a-zA-Z{2}.static String
FLOATING_POINT
Floating Point.static String
LETTERS
Letters a-z A-Z upper case and lower case.static String
RGB_COLOR
RGB Color schema in HEX: #000000 to #ffffff.static String
TEXT
Text.static String
TIME_24H
Time in 24 hour format: 00:00 to 23:59.static String
VERSION_NUMBER
Version number based on semantic versioning.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isDateAfter(org.joda.time.DateTime check, org.joda.time.DateTime after)
Check if is a given date after the given boundary.static boolean
isDateBefore(org.joda.time.DateTime check, org.joda.time.DateTime before)
Check if is a given date before the given boundary.static boolean
isDateInRange(org.joda.time.DateTime check, org.joda.time.DateTime min, org.joda.time.DateTime max)
Test if a given Date is inside a range between a min and max.static boolean
isIntegerInRange(int test, int min, int max)
Check if the Variable test inside the range of the borders min and max.static boolean
validate(String content, String regEx)
Validate a String against an regular expression and return true if the String matches the RegEx.
-
-
-
Field Detail
-
ASCII_CHARACTER
public static final String ASCII_CHARACTER
Printable ASCII Character: a-z A-Z.- See Also:
- Constant Field Values
-
BOOLEAN
public static final String BOOLEAN
Boolean. 0/1 true/false TRUE/FALSE- See Also:
- Constant Field Values
-
DIGIT
public static final String DIGIT
Digits form 0-9.- See Also:
- Constant Field Values
-
FLOATING_POINT
public static final String FLOATING_POINT
Floating Point.- See Also:
- Constant Field Values
-
LETTERS
public static final String LETTERS
Letters a-z A-Z upper case and lower case. No digits, space or special characters.- See Also:
- Constant Field Values
-
RGB_COLOR
public static final String RGB_COLOR
RGB Color schema in HEX: #000000 to #ffffff.- See Also:
- Constant Field Values
-
TEXT
public static final String TEXT
Text.- See Also:
- Constant Field Values
-
TIME_24H
public static final String TIME_24H
Time in 24 hour format: 00:00 to 23:59.- See Also:
- Constant Field Values
-
E_MAIL_ADDRESS
public static final String E_MAIL_ADDRESS
Test if a Email Address in the typical format, like:
_a-zA-Z0-9-(.)_a-zA-Z0-9-(@)[a-zA-Z0-9-]*(.)a-zA-Z{2}.- See Also:
- Constant Field Values
-
VERSION_NUMBER
public static final String VERSION_NUMBER
Version number based on semantic versioning. Major.Minor.Patch-SNAPSHOT : 1.0; 1.0-SNAPSHOT; 1.0.0-SNAPSHOT :: 000.000.000-ABCDEFGHIJ- See Also:
- Constant Field Values
-
-
Method Detail
-
isIntegerInRange
public static boolean isIntegerInRange(int test, int min, int max)
Check if the Variable test inside the range of the borders min and max. The borders and all numbers between are allowed values for the variable.- Parameters:
test
- as Integermin
- as Integermax
- as Integer- Returns:
- result as Boolean
-
isDateAfter
public static boolean isDateAfter(org.joda.time.DateTime check, org.joda.time.DateTime after)
Check if is a given date after the given boundary. If the check date equal to the after boundary, the validation will fail.
Sample:Validator.isDateAfter(new DateTime(), new DateTime(2015, 12, 31, 23, 59));
Validate to TRUE because: now() is after 2015- Parameters:
check
- as DateTimeafter
- as DateTime- Returns:
- true on success
-
isDateBefore
public static boolean isDateBefore(org.joda.time.DateTime check, org.joda.time.DateTime before)
Check if is a given date before the given boundary. If the check date equal to the before boundary, the validation will fail.
Sample:Validator.isDateBefore(new DateTime(2015, 12, 31, 23, 59), new DateTime());
Validate to TRUE because: 2015 is before now()- Parameters:
check
- as DateTimebefore
- as DateTime- Returns:
- true on success
-
isDateInRange
public static boolean isDateInRange(org.joda.time.DateTime check, org.joda.time.DateTime min, org.joda.time.DateTime max)
Test if a given Date is inside a range between a min and max. The boundaries are inside the range.- Parameters:
check
- as DateTimemin
- as DateTimemax
- as DateTime- Returns:
- true on success
-
-