Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
IndexAIPromptRequest
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 rules
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 messages
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Requests\v2\AIPrompt;
4
5use App\Http\Models\AIPrompts;
6use App\Http\Requests\v2\Parameter\Concerns\AuthorizesVengresoAdmin;
7use Illuminate\Foundation\Http\FormRequest;
8use Illuminate\Validation\Rule;
9
10/**
11 * Request for listing AI prompts.
12 *
13 * @property string|null $product Optional product filter (paragraph_rewrite, sentence_rewrite, fly_post, watch_youtube)
14 */
15class IndexAIPromptRequest extends FormRequest
16{
17    use AuthorizesVengresoAdmin;
18
19    /**
20     * Get the validation rules that apply to the request.
21     *
22     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
23     */
24    public function rules(): array
25    {
26        return [
27            'product' => ['sometimes', 'nullable', 'string', Rule::in(AIPrompts::PRODUCTS)],
28        ];
29    }
30
31    /**
32     * Get custom messages for validator errors.
33     *
34     * @return array<string, string>
35     */
36    public function messages(): array
37    {
38        return [
39            'product.in' => 'The product must be one of: '.implode(', ', AIPrompts::PRODUCTS),
40        ];
41    }
42}