35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreGoalRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'type' => ['required', Rule::in(['url_destination', 'event_match', 'duration', 'pages_per_session'])],
|
|
'default_value' => ['nullable', 'numeric', 'min:0'],
|
|
'is_active' => ['sometimes', 'boolean'],
|
|
|
|
'conditions.path' => ['required_if:type,url_destination', 'nullable', 'string', 'max:2048'],
|
|
'conditions.match_type' => ['required_if:type,url_destination', 'nullable', Rule::in(['exact', 'starts_with', 'contains', 'regex'])],
|
|
|
|
'conditions.event_name' => ['required_if:type,event_match', 'nullable', 'string', 'max:255'],
|
|
'conditions.event_category' => ['nullable', 'string', 'max:255'],
|
|
|
|
'conditions.seconds' => ['required_if:type,duration', 'nullable', 'integer', 'min:1'],
|
|
|
|
'conditions.page_count' => ['required_if:type,pages_per_session', 'nullable', 'integer', 'min:1'],
|
|
];
|
|
}
|
|
}
|