From 3529d19c8f30ff20136b86066e95398b9bac6199 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Tue, 5 Jul 2016 16:32:05 -0700 Subject: [PATCH] Added support for validation of multiple email in the `type: email` field (grav-plugin-email#31) --- CHANGELOG.md | 4 +++- system/src/Grav/Common/Data/Validation.php | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee75bfeb5..9a898ca1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # v1.1.0-rc.4 ## 06/xx/2016 +1. [](#improved) + * Added support for validation of multiple email in the `type: email` field [grav-plugin-email#31](https://github.com/getgrav/grav-plugin-email/issues/31) 1. [](#bugfix) - * Fix backend validation for file fields marked as required [grav-plugin-form#78](Fixes https://github.com/getgrav/grav-plugin-form/issues/78) + * Fix backend validation for file fields marked as required [grav-plugin-form#78](https://github.com/getgrav/grav-plugin-form/issues/78) # v1.1.0-rc.3 ## 06/21/2016 diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index c2911f2b2..0e2fc978d 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -404,7 +404,15 @@ public static function typeColor($value, array $params, array $field) */ public static function typeEmail($value, array $params, array $field) { - return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_EMAIL); + $values = !is_array($value) ? explode(',', preg_replace('/\s+/', '', $value)) : $value; + + foreach ($values as $value) { + if (!(self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_EMAIL))) { + return false; + } + } + + return true; } /**