68 lines
3.2 KiB
PHP
68 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Session;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
final class UpdateSessionRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->route('session')->user_id === auth()->id();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'basic_info' => ['sometimes', 'required', 'array'],
|
|
'basic_info.client_name' => ['required_with:basic_info', 'string', 'max:255'],
|
|
'basic_info.client_contact' => ['required_with:basic_info', 'string', 'max:255'],
|
|
'basic_info.lead_firm_name' => ['required_with:basic_info', 'string', 'max:255'],
|
|
'basic_info.lead_firm_contact' => ['required_with:basic_info', 'string', 'max:255'],
|
|
'answers' => ['sometimes', 'array'],
|
|
'answers.*.value' => ['nullable', 'string', 'in:yes,no,not_applicable'],
|
|
'answers.*.text_value' => ['nullable', 'string', 'max:10000'],
|
|
'additional_comments' => ['sometimes', 'nullable', 'string', 'max:10000'],
|
|
'complete' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Custom validation messages.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'basic_info.required' => 'Basic information is required.',
|
|
'basic_info.array' => 'Basic information must be a valid data structure.',
|
|
'basic_info.client_name.required_with' => 'The client name is required.',
|
|
'basic_info.client_name.string' => 'The client name must be text.',
|
|
'basic_info.client_name.max' => 'The client name cannot exceed 255 characters.',
|
|
'basic_info.client_contact.required_with' => 'The client contact is required.',
|
|
'basic_info.client_contact.string' => 'The client contact must be text.',
|
|
'basic_info.client_contact.max' => 'The client contact cannot exceed 255 characters.',
|
|
'basic_info.lead_firm_name.required_with' => 'The lead firm name is required.',
|
|
'basic_info.lead_firm_name.string' => 'The lead firm name must be text.',
|
|
'basic_info.lead_firm_name.max' => 'The lead firm name cannot exceed 255 characters.',
|
|
'basic_info.lead_firm_contact.required_with' => 'The lead firm contact is required.',
|
|
'basic_info.lead_firm_contact.string' => 'The lead firm contact must be text.',
|
|
'basic_info.lead_firm_contact.max' => 'The lead firm contact cannot exceed 255 characters.',
|
|
'answers.array' => 'Answers must be a valid data structure.',
|
|
'answers.*.value.in' => 'Answer value must be yes, no, or not_applicable.',
|
|
'answers.*.text_value.string' => 'Answer text must be text.',
|
|
'answers.*.text_value.max' => 'Answer text cannot exceed 10000 characters.',
|
|
'additional_comments.string' => 'Additional comments must be text.',
|
|
'additional_comments.max' => 'Additional comments cannot exceed 10000 characters.',
|
|
'complete.boolean' => 'The complete flag must be true or false.',
|
|
];
|
|
}
|
|
}
|