-
app/Rules/OneEmailPerLine.php
Open in GitHubuse Illuminate\Contracts\Validation\Rule; class OneEmailPerLine implements Rule { public function passes($attribute, $value) { if ($value === null || empty(trim($value))) return true; foreach (preg_split("/\r\n|\n|\r/", $value) as $email) { $email = trim($email); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return false; } } return true; } public function message() { return 'You need one valid email per line.'; } }
-
app/Http/Requests/UserFormRequest.php
Open in GitHubuse App\Models\Forms\Form; use App\Rules\OneEmailPerLine; use Illuminate\Validation\Rule; use App\Rules\FormPropertyLogicRule; abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest { public function rules() { return [ // 'notification_emails' => ['required_if:notifies,1', new OneEmailPerLine ], // ]; } // }