Way to Validate Email Addresses

Hello Everyone:
I was wondering if anyone has developed a way to validate email addresses?

OriginalPostID-204914

OriginalPostID-204914

  Discussion posts and replies are publicly visible

Parents
  • Adding to what @philb said above, you can use the below code snippet to validate email address through regex plugin.

    regexmatch("\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b",ri!email)
  • The fully RFC 822 compliant regex is inefficient and obscure for validate email address because of its length. Fortunately, RFC 822 was superseded twice and the current specification for email addresses is RFC 5322. RFC 5322 leads to a regex that can be understood if studied for a few minutes and is efficient enough for actual use.

    If you use HTML5, use this code:

    <input type="email" name="email" required placeholder="Enter a valid email address">

  • Since this zombie thread has already been dredged back up anyway....

    A while ago I switched to a regex-based validation solution because despite the best updates to the OOB approach posted below originally, there were still corner cases that were hard to handle sufficiently without the inherent power of RegEx matching.

    The RegEx originally posted by Shailendras almost 6 years ago fails in some valid and common corner cases, including name or domain parts with multiple pieces separated by ".", such as "mike@mail.appian.com" etc.

    Eventually I was able to work up the following RegEx match function by a combination of a few different sources and my own testing, which passes a fairly robust set of test cases, screenshotted below:

    regexmatch(
      pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
      searchString: ri!email,
      regexFlags: "si"
    )

    The above code simply replaced my old, OOTB code in the expression rule I'd been using (i actually kept it, but commented out, for posterity).

    I should also note that the modern version of the People Functions plug-in seems to have a built-in expression funciton, validateEmailAddress(), which I can confirm passes all of the above test cases as well.

Reply
  • Since this zombie thread has already been dredged back up anyway....

    A while ago I switched to a regex-based validation solution because despite the best updates to the OOB approach posted below originally, there were still corner cases that were hard to handle sufficiently without the inherent power of RegEx matching.

    The RegEx originally posted by Shailendras almost 6 years ago fails in some valid and common corner cases, including name or domain parts with multiple pieces separated by ".", such as "mike@mail.appian.com" etc.

    Eventually I was able to work up the following RegEx match function by a combination of a few different sources and my own testing, which passes a fairly robust set of test cases, screenshotted below:

    regexmatch(
      pattern: "^[A-Z0-9\'\+\&\%_-]+(\.{0,1}[A-Z0-9\'\+\&\%_-]+)*[@]{1}[A-Z0-9.-]*[A-Z0-9-]+[.]{1}[A-Z]{2,6}$",
      searchString: ri!email,
      regexFlags: "si"
    )

    The above code simply replaced my old, OOTB code in the expression rule I'd been using (i actually kept it, but commented out, for posterity).

    I should also note that the modern version of the People Functions plug-in seems to have a built-in expression funciton, validateEmailAddress(), which I can confirm passes all of the above test cases as well.

Children
No Data