Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
UpsertDomainRequest
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 authorize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 rules
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Requests\v2\UserFieldInjection;
4
5use Illuminate\Foundation\Http\FormRequest;
6
7/**
8 * Request for upserting a domain entry in user field injection config.
9 *
10 * @property array<array{selector: string, is_inside_shadow_dom?: bool, inside_of?: string, not_inside_of?: string, has_parent_selector?: string, icon_offset_bottom?: int}> $fields The field configurations for this domain
11 */
12class UpsertDomainRequest extends FormRequest
13{
14    /**
15     * Determine if the user is authorized to make this request.
16     */
17    public function authorize(): bool
18    {
19        return $this->user() !== null;
20    }
21
22    /**
23     * Get the validation rules that apply to the request.
24     *
25     * @return array<string, mixed>
26     */
27    public function rules(): array
28    {
29        return [
30            'fields' => ['required', 'array', 'min:1'],
31            'fields.*' => ['array'],
32            'fields.*.selector' => ['required', 'string'],
33            'fields.*.is_inside_shadow_dom' => ['sometimes', 'boolean'],
34            'fields.*.inside_of' => ['sometimes', 'string'],
35            'fields.*.not_inside_of' => ['sometimes', 'string'],
36            'fields.*.has_parent_selector' => ['sometimes', 'string'],
37            'fields.*.icon_offset_bottom' => ['sometimes', 'integer'],
38        ];
39    }
40}