Package org.europa.together.utils
Class Validator
java.lang.Object
org.europa.together.utils.Validator
A simple RexEx Validator.
### REGEX VALIDATION PATTERN
### * = 0 or more quantifier
### + = 1 or more quantifier
### ? = 0 or 1 quantifier
### REGEX VALIDATION PATTERN
### * = 0 or more quantifier
### + = 1 or more quantifier
### ? = 0 or 1 quantifier
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Printable ASCII character: a-z A-Z.static final String
Boolean.static final String
Digits form 0-9.static final String
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 final String
Floating point.static final String
IP Adress (Version 4) with optional port e.static final String
Letters a-z A-Z upper case and lower case.static final String
RGB Color schema in HEX: #000000 to #ffffff.static final String
Version number based on semantic versioning.static final String
Text.static final String
Time in 24 hour format: 00:00 to 23:59. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isDateAfter
(ZonedDateTime check, ZonedDateTime after) Check if is a given date after the given boundary.static boolean
isDateBefore
(ZonedDateTime check, ZonedDateTime before) Check if is a given date before the given boundary.static boolean
isDateInRange
(ZonedDateTime check, ZonedDateTime min, ZonedDateTime 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
Test if a 10 or 13 digit ISBN number is valid.static boolean
Validate a String against an regular expression and return true if the String matches the RegEx.
-
Field Details
-
ASCII_CHARACTER
Printable ASCII character: a-z A-Z.- See Also:
-
BOOLEAN
Boolean. 0/1 true/false TRUE/FALSE- See Also:
-
DIGIT
Digits form 0-9.- See Also:
-
FLOATING_POINT
Floating point.- See Also:
-
LETTERS
Letters a-z A-Z upper case and lower case. No digits, space or special characters.- See Also:
-
RGB_COLOR
RGB Color schema in HEX: #000000 to #ffffff.- See Also:
-
TEXT
Text.- See Also:
-
TIME_24H
Time in 24 hour format: 00:00 to 23:59.- See Also:
-
IP4_ADDRESS
IP Adress (Version 4) with optional port e. g.: 127.0.0.1:80 (1-255).(0-255).(0-255).(0-255):(1-65535)- See Also:
-
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:
-
SEMANTIC_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:
-
-
Method Details
-
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:
- true on success
-
isDateAfter
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
Convert java.util.Date to ZonedDateTimeZonedDateTime.from(Date.toInstant();
- Parameters:
check
- as DateTimeafter
- as DateTime- Returns:
- true on success
-
isDateBefore
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()
Convert java.util.Date to ZonedDateTimeZonedDateTime.from(Date.toInstant();
- Parameters:
check
- as DateTimebefore
- as DateTime- Returns:
- true on success
-
isDateInRange
Test if a given date is inside a range between a min and max. The boundaries are inside the range.
Convert java.util.Date to ZonedDateTimeZonedDateTime.from(Date.toInstant();
- Parameters:
check
- as DateTimemin
- as DateTimemax
- as DateTime- Returns:
- true on success
-
isIsbn
Test if a 10 or 13 digit ISBN number is valid.- Parameters:
isbn
- as String- Returns:
- true on success
- Throws:
NumberFormatException
-
validate
Validate a String against an regular expression and return true if the String matches the RegEx.- Parameters:
content
- as StringregEx
- as String- Returns:
- true on success
-