Skip to content

Commit

Permalink
Added support for validation of multiple email in the type: email f…
Browse files Browse the repository at this point in the history
…ield (grav-plugin-email#31)
  • Loading branch information
w00fz committed Jul 5, 2016
1 parent a6eef19 commit 3529d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 9 additions & 1 deletion system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 3529d19

Please sign in to comment.