54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\User;
|
|
|
|
use App\Extension\HookManager;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* 이메일 중복 확인 요청 검증
|
|
*/
|
|
class CheckEmailRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'email' => 'required|email|max:255',
|
|
'exclude_user_id' => ['nullable', 'uuid', Rule::exists(User::class, 'uuid')],
|
|
];
|
|
|
|
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
|
return HookManager::applyFilters('core.user.check_email_validation_rules', $rules, $this);
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'email.required' => __('user.validation.email_required'),
|
|
'email.email' => __('user.validation.email_invalid'),
|
|
'email.max' => __('user.validation.email_max'),
|
|
'exclude_user_id.uuid' => __('user.validation.exclude_user_id_uuid'),
|
|
'exclude_user_id.exists' => __('user.validation.exclude_user_id_exists'),
|
|
];
|
|
}
|
|
} |