The email validation rule, like nearly all the built-in rules, is available in Laravel's Illuminate\Validation\Validator class (in 4.2 at least). Looking at the specific method, it looks like this:
/**
* Validate that an attribute is a valid e-mail address.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
protected function validateEmail($attribute, $value)
{
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}
As you can see, it's simply a convenience method for the filter_var PHP method. One simple solution then would be to create a custom validation rule something like this:
Validator::extend('isArrayOfEmails', function($attribute, $value, $parameters)
{
// define closure separately for readability
$checkEmails = function($carry, $email){
return $carry && filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
};
// validate that the value given is an array of valid email addresses
return (is_array($attribute) and array_reduce($values,$checkEmails,true));
});
minor edit: corrected Laravel version to 4.2 in first para.