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
FieldsModifier and TypeFieldDescriptionstatic final StringPrintable ASCII character: a-z A-Z.static final StringBoolean. 0/1 true/false TRUE/FALSEstatic final StringDigits form 0-9.static final StringGeneral E-Mail Regex (RFC 5322 Official Standard.static final StringFloating point.static final StringIP Adress (Version 4) with optional port e. g.: 127.0.0.1:80 (1-255).(0-255).(0-255).(0-255):(1-65535)static final StringLetters a-z A-Z upper case and lower case.static final StringRGB Color schema in HEX: #000000 to #ffffff.static final StringVersion number based on semantic versioning.static final StringText.static final StringTime in 24 hour format: 00:00 to 23:59. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisDateAfter(ZonedDateTime check, ZonedDateTime after) Check if is a given date after the given boundary.static booleanisDateBefore(ZonedDateTime check, ZonedDateTime before) Check if is a given date before the given boundary.static booleanisDateInRange(ZonedDateTime check, ZonedDateTime min, ZonedDateTime max) Test if a given date is inside a range between a min and max.static booleanisIntegerInRange(int test, int min, int max) Check if the variable test inside the range of the borders min and max.static booleanTest if a 10 or 13 digit ISBN number is valid.static booleanluhnNumberChecksum(String numbers) Luhns Algortihm is secure way to find for an number it's corrsponding checksum (validation key).static booleanValidate 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
General E-Mail Regex (RFC 5322 Official Standard.- 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
-
luhnNumberChecksum
Luhns Algortihm is secure way to find for an number it's corrsponding checksum (validation key). This algorithm is used by Visa, Mastercard and others to verify the credit card number.This mechanism can also used to verify gift card codes.
You need to place the number wich have verified and it's corresponding checksum. If the validation succeed by the correct checksum the method return tue.- Parameters:
numbers- as Integer- Returns:
- true on success
-
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
-