Class Validator


  • public final class Validator
    extends Object
    A simple RexEx Validator.
    • 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 Integer
        min - as Integer
        max - 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 DateTime
        after - 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 DateTime
        before - 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 DateTime
        min - as DateTime
        max - as DateTime
        Returns:
        true on success
      • 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