dealhub/app/Http/Requests/StoreRegisterdUser.php
kusowl ec7ae434c4 feat(registration): User registration
- add validation, and prepare the model.
- show errors in form components
- refactor route file to make register route as resource
2026-01-09 14:00:42 +05:30

36 lines
997 B
PHP

<?php
namespace App\Http\Requests;
use App\Enums\UserTypes;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;
class StoreRegisterdUser 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 [
'name' => 'required|string|max:255',
'password' => ['required', 'confirmed', Password::min(8)->letters()->mixedCase()->numbers()->symbols()],
'email' => 'required|string|email|max:255|unique:users',
'role' => ['required', Rule::in(UserTypes::values()), Rule::notIn(UserTypes::Admin->value)],
];
}
}