Laravel 5&在单个字段中验证多个电子邮件地址

时间:2016-09-22 14:52:00

标签: php validation email laravel-5

我知道在Laravel中你可以设置输入字段的验证规则,例如:

    $return =  [
        'first_name' => 'required|max:300|min:3',
        'last_name' => 'required|max:300|min:3',
        'email' => 'required|email,
    ];

有没有办法轻松为使用逗号分隔的电子邮件地址(test@email.com, wibble@test.com)的单个字段设置此类验证,还是需要通过将它们分开并单独检查每个电子邮件地址来手动验证这些?< / p>

1 个答案:

答案 0 :(得分:-1)

这可能是您正在寻找的:

$rules = array(
            'email_addresses' => 'required',
            'email_addresses.*' => 'email'
        );

$messages = array(
            'email_addresses.required' => 'Email Addresses Required',
            'email_addresses.email' => ''
        );