58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\ContactUs\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CreateContactUsRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'full_name' => 'required|string|max:200|regex:/^[a-zA-Z. ]+$/',
|
|
'address' => 'sometimes|nullable|string|max:200',
|
|
'email' => 'sometimes|nullable|email',
|
|
'subject' => 'sometimes|nullable|string|max:1000',
|
|
'message' => 'required|string|max:1000',
|
|
'phone' => ['sometimes','nullable','regex:/^\+?\d{7,15}$/'],
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'full_name.required' => 'The full name field is required.',
|
|
'full_name.string' => 'The full name must be a string.',
|
|
'full_name.max' => 'The full name may not be greater than 200 characters.',
|
|
'full_name.regex' => 'The full name may only contain letters, dots, and spaces.',
|
|
|
|
'address.string' => 'The address must be a string.',
|
|
'address.max' => 'The address may not be greater than 200 characters.',
|
|
|
|
'email.email' => 'Invalid email format.',
|
|
|
|
'subject.string' => 'The subject must be a string.',
|
|
'subject.max' => 'The subject may not be greater than 1000 characters.',
|
|
|
|
'message.required' => 'The message field is required.',
|
|
'message.string' => 'The message must be a string.',
|
|
'message.max' => 'The message may not be greater than 1000 characters.',
|
|
|
|
'phone.numeric' => 'The phone must be a number.',
|
|
'phone.digits_between' => 'The phone must be a number between 7 and 15 digits long.',
|
|
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|