init
This commit is contained in:
36
app/Http/Requests/VehicleEnquiryRequest.php
Normal file
36
app/Http/Requests/VehicleEnquiryRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class VehicleEnquiryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'registration_number' => ['required', 'string', 'max:8', 'regex:/^(?=.*\d)[A-Za-z0-9 ]+$/'],
|
||||
'contact_data' => ['nullable', 'array'],
|
||||
'contact_data.name' => ['nullable', 'string', 'max:255'],
|
||||
'contact_data.email' => ['nullable', 'email', 'max:255'],
|
||||
'contact_data.phone' => ['nullable', 'string', 'max:50'],
|
||||
'contact_data.address' => ['nullable', 'string', 'max:500'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'registration_number.required' => 'Vehicle registration number is required',
|
||||
'registration_number.max' => 'Vehicle registration number must not exceed 8 characters',
|
||||
'registration_number.regex' => 'Invalid registration number format',
|
||||
'contact_data.array' => 'Contact data must be a valid object',
|
||||
'contact_data.email.email' => 'Please provide a valid email address',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user