Class Validator

java.lang.Object
io.github.multiform_validator.Validator

public class Validator extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isAscii(String value)
    Checks if the given string contains only ASCII characters.
    static boolean
    Checks if the given string is a valid Base64 encoded string.
    static boolean
    Checks if the given string is a valid CEP (Brazilian postal code).
    static boolean
    isDate(String dateStr)
    Checks if the given string is a valid date.
    static boolean
    Checks if the given string is a valid decimal number.
    static boolean
    isEmail(String email)
    Checks if the given string is a valid email address.
    static boolean
    isMACAddress(String macAddress)
    Checks if the given string is a valid MAC address.
    static boolean
    isMD5(String value)
    Checks if the given string is a valid MD5 hash.
    static boolean
    Checks if the given string is a valid number.
    static boolean
    isPort(int port)
    Checks if the given port number is valid.
    static boolean
    isPort(String port)
    Checks if the given string is a valid port number.
    static boolean
    isPostalCode(String postalCode)
    Checks if the given string is a valid postal code.
    static boolean
    isTime(String time)
    Checks if the given string is a valid time in the format "HH:mm:ss" or "HH:mm:ss a".

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isAscii

      public static boolean isAscii(String value)
      Checks if the given string contains only ASCII characters.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string contains only ASCII characters, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isBase64

      public static boolean isBase64(String value)
      Checks if the given string is a valid Base64 encoded string.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string is a valid Base64 encoded string, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isCEP

      public static boolean isCEP(String cep)
      Checks if the given string is a valid CEP (Brazilian postal code).
      Parameters:
      cep - the string to be checked
      Returns:
      true if the string is a valid CEP, false otherwise
    • isDate

      public static boolean isDate(String dateStr)
      Checks if the given string is a valid date. The date can be in the following formats:
      Parameters:
      dateStr - the string to be checked
      Returns:
      true if the string is a valid date, false otherwise
    • isDecimal

      public static boolean isDecimal(String value)
      Checks if the given string is a valid decimal number.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string is a valid decimal number, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isEmail

      public static boolean isEmail(String email)
      Checks if the given string is a valid email address.
      Parameters:
      email - the string to be checked
      Returns:
      true if the string is a valid email address, false otherwise
      Throws:
      NullPointerException - if the email is null
    • isMACAddress

      public static boolean isMACAddress(String macAddress)
      Checks if the given string is a valid MAC address.
      Parameters:
      macAddress - the string to be checked
      Returns:
      true if the string is a valid MAC address, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isMD5

      public static boolean isMD5(String value)
      Checks if the given string is a valid MD5 hash.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string is a valid MD5 hash, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isNumber

      public static boolean isNumber(String value)
      Checks if the given string is a valid number.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string is a valid number, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isPort

      public static boolean isPort(int port)
      Checks if the given port number is valid.
      Parameters:
      port - the port number to be checked
      Returns:
      true if the port number is valid, false otherwise
    • isPort

      public static boolean isPort(String port)
      Checks if the given string is a valid port number.
      Parameters:
      port - the string to be checked
      Returns:
      true if the string is a valid port number, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isPostalCode

      public static boolean isPostalCode(String postalCode)
      Checks if the given string is a valid postal code.
      Parameters:
      postalCode - the string to be checked
      Returns:
      true if the string is a valid postal code, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty
    • isTime

      public static boolean isTime(String time)
      Checks if the given string is a valid time in the format "HH:mm:ss" or "HH:mm:ss a".
      Parameters:
      time - the string to be checked
      Returns:
      true if the string is a valid time, false otherwise
      Throws:
      IllegalArgumentException - if the input value is null or empty