I have done all the things for the validation for the variable in laravel but for emails I got one simple problem.
From doc of Laravel,
'email' => 'required|email'
I got to know this is for only one email address but for like,
email=abc@xyz.com,xyz@abc.com, def@ghi,com
When I send array of the email i still get email is not a valid email. I have done more like,
'email' => 'required|email|array'
But I still got error. can any body help.
Thanks,
I did it like this. Working good for me. if email or emails (email1@gmail.com, email2@yahoo.com, email3@gmail.com) are coming from a Form like this following custom validator works. This need to be added to - AppServiceProvider.php - file. And new rule is - 'emails'.
And in your controller, it can be used like this:
You need to write custom Validator, which will take the array and validate each ofthe emails in array manually. In Laravel 5 Request you can do something like that
In 5.6 or above you can define your validator rule as follows:
'email.*' => 'required|email'
This will expect the
email
key to be an array of valid email addresses.Laravel 5.2 introduced array validation and you can easily validate array of emails :)
All you need is exploding the string to array.
https://laravel.com/docs/5.2/validation#validating-arrays