Hello Everyone:I was wondering if anyone has developed a way to validate email addresses?
Discussion posts and replies are publicly visible
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 "firstname.lastname@example.org" 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:
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.
© 2022 Appian. All rights reserved.