Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CheckOutputPromptFormRequest
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 rules
100.00% covered (success)
100.00%
23 / 23
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Requests\v2\FlyAI;
4
5use App\Http\Requests\v2\Parameter\Concerns\AuthorizesVengresoAdmin;
6use Illuminate\Foundation\Http\FormRequest;
7
8/**
9 * Request for the admin check-output-prompt endpoint.
10 *
11 * Unified validation that accepts either flyengage or flypost params
12 * depending on the feature field. Used by admins to test/debug AI prompts.
13 *
14 * @property string $feature The AI feature to test (flyengage or flypost)
15 * @property string $prompt_id The PromptType ID to test
16 * @property bool $dry_run If true, return only the assembled prompt without calling AI
17 * @property bool $include_hashtags Whether to include hashtags in the output
18 * @property bool $include_emojis Whether to include emojis in the output
19 * @property array $context Post context data (required for flyengage)
20 * @property bool $is_reply Whether this is a reply (required for flyengage)
21 * @property string $prompt_language_id PromptLanguage ID (required for flypost)
22 * @property string $length_of_post_id PromptLengthOfPost ID (required for flypost)
23 * @property string|null $topic Topic for thought leadership posts
24 * @property string|null $insert_role Role for hiring posts
25 * @property string|null $youtube_url YouTube URL for video-based posts
26 * @property string|null $blog_url Blog URL for article-based posts
27 * @property string|null $prompt_company_new_update_id PromptCompanyNewUpdate ID
28 * @property string|null $prompt_personal_milestone_id PromptPersonalMilestone ID
29 * @property string|null $persona_id UserPersona ID
30 * @property string|null $prompt_tone_id PromptTone ID
31 * @property string|null $custom_prompt_id CustomPrompts ID
32 * @property string|null $additional_instructions Additional instructions for the AI
33 * @property bool $is_regenerate Whether this is a regeneration request
34 * @property string|null $uniqueId Unique identifier for tracking
35 */
36class CheckOutputPromptFormRequest extends FormRequest
37{
38    use AuthorizesVengresoAdmin;
39
40    /**
41     * Get the validation rules that apply to the request.
42     *
43     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
44     */
45    public function rules(): array
46    {
47        return [
48            'feature' => 'required|string|in:flyengage,flypost',
49            'prompt_id' => 'required|string|exists:ai_prompts,_id',
50            'dry_run' => 'sometimes|boolean',
51            'include_hashtags' => 'required|boolean',
52            'include_emojis' => 'required|boolean',
53
54            // Engage-specific
55            'context' => 'required_if:feature,flyengage|array',
56            'is_reply' => 'required_if:feature,flyengage|boolean',
57
58            // Post-specific
59            'prompt_language_id' => 'required_if:feature,flypost|string|exists:prompt_language,_id',
60            'length_of_post_id' => 'required_if:feature,flypost|string|exists:prompt_length_of_post,_id',
61            'topic' => 'sometimes|nullable|string',
62            'insert_role' => 'sometimes|nullable|string',
63            'youtube_url' => 'sometimes|nullable|string',
64            'blog_url' => 'sometimes|nullable|string',
65            'prompt_company_new_update_id' => 'sometimes|nullable|string|exists:prompt_company_new_update,_id',
66            'prompt_personal_milestone_id' => 'sometimes|nullable|string|exists:prompt_personal_milestone,_id',
67
68            // Shared optional
69            'persona_id' => 'sometimes|nullable|string|exists:user_persona,_id',
70            'prompt_tone_id' => 'sometimes|nullable|string|exists:prompt_tone,_id',
71            'custom_prompt_id' => 'sometimes|nullable|string|exists:custom_prompts,_id',
72            'additional_instructions' => 'sometimes|nullable|string',
73            'is_regenerate' => 'sometimes|boolean',
74            'uniqueId' => 'sometimes|nullable|string',
75        ];
76    }
77}