Class EmailAddressHelper

java.lang.Object
com.helger.commons.email.EmailAddressHelper

@Immutable public final class EmailAddressHelper extends Object
Perform simple email address validation based on a regular expression.
Author:
Philip Helger
  • Field Details

    • EMAIL_ADDRESS_PATTERN

      public static final String EMAIL_ADDRESS_PATTERN
      This is the email RegEx :)
      See Also:
    • EMAIL_ADDRESS_PATTERN_SIMPLE

      public static final String EMAIL_ADDRESS_PATTERN_SIMPLE
      This is the simple email RegEx that deals with Unicode email addresses. Based on https://github.com/itplr-kosit/validator-configuration-xrechnung/issues/109
      See Also:
  • Method Details

    • getUnifiedEmailAddress

      @Nullable public static String getUnifiedEmailAddress(@Nullable String sEmailAddress)
      Get the unified version of an email address. It trims leading and trailing spaces and lower-cases the email address.
      Parameters:
      sEmailAddress - The email address to unify. May be null.
      Returns:
      The unified email address or null if the input address is null.
    • isValid

      public static boolean isValid(@Nullable String sEmailAddress)
      Checks if a value is a valid e-mail address according to the original, complex regular expression (see EMAIL_ADDRESS_PATTERN).
      Parameters:
      sEmailAddress - The value validation is being performed on. A null value is considered invalid.
      Returns:
      true if the email address is valid, false otherwise.
    • isValidForSimplePattern

      public static boolean isValidForSimplePattern(@Nullable String sEmailAddress)
      Checks if a value is a valid e-mail address according to the simple regular expression (see EMAIL_ADDRESS_PATTERN_SIMPLE). The idea is, that all email addresses valid with isValid(String) are still valid with this one.
      Parameters:
      sEmailAddress - The value validation is being performed on. A null value is considered invalid.
      Returns:
      true if the email address is valid, false otherwise.