36 lines
938 B
PHP
36 lines
938 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class AccountEmailRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if (is_string($this->input('email'))) {
|
|
$this->merge(['email' => strtolower(trim($this->input('email')))]);
|
|
}
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return ['email' => ['required', 'string', 'email:rfc', 'max:255']];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'email.required' => __('Укажи email аккаунта.'),
|
|
'email.string' => __('Укажи корректный email.'),
|
|
'email.email' => __('Укажи корректный email.'),
|
|
'email.max' => __('Email не должен быть длиннее 255 символов.'),
|
|
];
|
|
}
|
|
}
|