2024-02-29 13:42:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Rules;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
2024-03-30 15:40:42 +01:00
|
|
|
class IsValidEmailList implements ValidationRule
|
2024-02-29 13:42:28 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the validation rule.
|
|
|
|
*/
|
2024-03-29 09:42:54 +01:00
|
|
|
public function validate(string $attribute, mixed $value, Closure $fail) : void
|
2024-02-29 13:42:28 +01:00
|
|
|
{
|
|
|
|
$emails = explode('|', $value);
|
|
|
|
|
|
|
|
$pass = Validator::make(
|
|
|
|
$emails,
|
|
|
|
[
|
|
|
|
'*' => 'email',
|
|
|
|
]
|
|
|
|
)->passes();
|
|
|
|
|
|
|
|
if (! $pass) {
|
|
|
|
$fail('validation.custom.email.IsValidEmailList')->translate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|