44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CustomRegisterRequest 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
|
|
{
|
|
return [
|
|
'email' => [
|
|
'required',
|
|
'string',
|
|
'email',
|
|
'max:255',
|
|
'unique:users',
|
|
function ($attribute, $value, $fail) {
|
|
$allowedDomains = ['polije.ac.id', 'student.polije.ac.id'];
|
|
$emailDomain = substr(strrchr($value, "@"), 1);
|
|
|
|
if (!in_array($emailDomain, $allowedDomains)) {
|
|
$fail('Domain emailnya harus @polije.ac.id atau @student.polije.ac.id.');
|
|
}
|
|
},
|
|
],
|
|
'password' => ['required', 'string', 'min:8'],
|
|
'confirm-password' => ['required', 'same:password'],
|
|
];
|
|
}
|
|
} |