#7914 - Fix for contacts being empty or s tring (#7915)
[openemr.git] / src / Common / Utils / ValidationUtils.php
blobc42f1a38ae1b8be559991bfd9f6cbcab8fd4120b
1 <?php
3 /**
4 * ValidationUtils is intended for validation methods that are used in OpenEMR.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Cassian LUP <cassi.lup@gmail.com>
9 * @author Stephen Nielson <snielson@discoverandchange.com>
10 * @copyright Copyright (c) 2011 Cassian LUP <cassi.lup@gmail.com>
11 * @copyright Copyright (c) 2022 Discover and Change, Inc <snielson@discoverandchange.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 namespace OpenEMR\Common\Utils;
17 class ValidationUtils
19 public static function isValidEmail($email)
21 // FILTER_FLAG_EMAIL_UNICODE allows for unicode characters in the local (part before the @) of the email
22 if (filter_var($email, FILTER_VALIDATE_EMAIL, FILTER_FLAG_EMAIL_UNICODE)) {
23 // TODO: OpenEMR has used this validator regex for 11+ years... leaving this line in case we need to revert
24 // on January 30th 2023 added the ability to support SMTP label addresses such as myname+label@gmail.com
25 // Fixes #6159 (openemr/openemr/issues/6159)
27 // if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-\+]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)) {
28 return true;
31 return false;