Files
sogandAsghary.Project09/app/Http/Requests/Auth/RegisterPostRequest.php
T
2026-08-22 11:11:28 -07:00

113 lines
2.6 KiB
PHP

<?php
namespace App\Http\Requests\Auth;
use App\Enums\UserGenderStatus;
use App\Enums\UserMaritalStatus;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class RegisterPostRequest 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, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'first_name' => [
'required',
'persian_alpha',
'min:2',
'max:100',
],
'last_name' => [
'required',
'persian_alpha',
'min:3',
'max:100',
],
'username' => [
'required',
'regex:/^[a-zA-Z0-9\x{0600}-\x{06FF}]+$/u',
'min:3',
'max:20',
'unique:users,username'
],
'national_code' => [
'required',
'ir_national_id',
'digits:10',
'unique:users,national_code',
],
'gender'=>[
'required',
new Enum(UserGenderStatus::class),
],
'marital_status'=>[
'required',
new Enum(UserMaritalStatus::class),
],
'spouse_name'=>[
'nullable',
'string',
'persian_alpha',
'max:256',
],
'file_id ' => [
'nullable',
'image',
'mimes:jpg,jpeg,png,webp',
'max:800',
],
'province_id' => [
'nullable',
'exists:provinces,id',
],
'city_id' => [
'nullable',
'exists:cities,id',
],
'password' => [
'required',
'string',
'min:6',
'max:255',
'confirmed'
],
'mobile' => [
'required',
'ir_mobile:zero',
'unique:users,mobile',
],
'email' => [
'required',
'max:150',
'email',
'unique:users,email',
]
];
}
}