Class Validator

java.lang.Object
org.europa.together.utils.Validator

public final class Validator extends Object
A simple RexEx Validator.
### REGEX VALIDATION PATTERN
### * = 0 or more quantifier
### + = 1 or more quantifier
### ? = 0 or 1 quantifier
  • Field Details

    • ASCII_CHARACTER

      public static final String ASCII_CHARACTER
      Printable ASCII character: a-z A-Z.
      See Also:
    • BOOLEAN

      public static final String BOOLEAN
      Boolean. 0/1 true/false TRUE/FALSE
      See Also:
    • DIGIT

      public static final String DIGIT
      Digits form 0-9.
      See Also:
    • FLOATING_POINT

      public static final String FLOATING_POINT
      Floating point.
      See Also:
    • LETTERS

      public static final String LETTERS
      Letters a-z A-Z upper case and lower case. No digits, space or special characters.
      See Also:
    • RGB_COLOR

      public static final String RGB_COLOR
      RGB Color schema in HEX: #000000 to #ffffff.
      See Also:
    • TEXT

      public static final String TEXT
      Text.
      See Also:
    • TIME_24H

      public static final String TIME_24H
      Time in 24 hour format: 00:00 to 23:59.
      See Also:
    • IP4_ADDRESS

      public static final String 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

      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:
    • SEMANTIC_VERSION_NUMBER

      public static final String 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 Integer
      min - as Integer
      max - as Integer
      Returns:
      true on success
    • isDateAfter

      public static boolean isDateAfter(ZonedDateTime check, ZonedDateTime 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

      Convert java.util.Date to ZonedDateTime ZonedDateTime.from(Date.toInstant();
      Parameters:
      check - as DateTime
      after - as DateTime
      Returns:
      true on success
    • isDateBefore

      public static boolean isDateBefore(ZonedDateTime check, ZonedDateTime 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()

      Convert java.util.Date to ZonedDateTime ZonedDateTime.from(Date.toInstant();
      Parameters:
      check - as DateTime
      before - as DateTime
      Returns:
      true on success
    • isDateInRange

      public static boolean isDateInRange(ZonedDateTime check, ZonedDateTime min, ZonedDateTime max)
      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 ZonedDateTime ZonedDateTime.from(Date.toInstant();
      Parameters:
      check - as DateTime
      min - as DateTime
      max - as DateTime
      Returns:
      true on success
    • isIsbn

      public static boolean isIsbn(String isbn) throws NumberFormatException
      Test if a 10 or 13 digit ISBN number is valid.
      Parameters:
      isbn - as String
      Returns:
      true on success
      Throws:
      NumberFormatException
    • validate

      public static boolean validate(String content, String regEx)
      Validate a String against an regular expression and return true if the String matches the RegEx.
      Parameters:
      content - as String
      regEx - as String
      Returns:
      true on success