refactor(ai-create): clarify prompt-rule naming and label the counter
- Rename AiPromptRules::promptRule() to wizardPromptRule() so the asymmetry is explicit: only the create wizard carries a minimum; the editor's generation reuses just the shared maximum. - Add aria-live and a data-testid to the prompt counter so the over-limit state is announced to assistive tech and reachable from browser tests.
This commit is contained in:
parent
c432034dd1
commit
e7f93f4aef
3 changed files with 7 additions and 3 deletions
|
|
@ -34,7 +34,7 @@ public function rules(): array
|
|||
],
|
||||
'social_account_id' => ['nullable', 'uuid'],
|
||||
'image_count' => ['nullable', 'integer', 'min:0', 'max:10'],
|
||||
'prompt' => AiPromptRules::promptRule(),
|
||||
'prompt' => AiPromptRules::wizardPromptRule(),
|
||||
'date' => ['nullable', 'date_format:Y-m-d'],
|
||||
'template' => ['sometimes', 'string', Rule::enum(ContentStyle::class)],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ class AiPromptRules
|
|||
public const PROMPT_MAX_LENGTH = 2000;
|
||||
|
||||
/**
|
||||
* Validation rules for the create wizard's generation prompt.
|
||||
* Validation rules for the create wizard's generation prompt. The editor's
|
||||
* content generation reuses only PROMPT_MAX_LENGTH — it has no minimum,
|
||||
* since it has no character counter to mirror one.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function promptRule(): array
|
||||
public static function wizardPromptRule(): array
|
||||
{
|
||||
return ['required', 'string', 'min:'.self::PROMPT_MIN_LENGTH, 'max:'.self::PROMPT_MAX_LENGTH];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,6 +364,8 @@ const startGeneration = async () => {
|
|||
class="min-h-[140px] resize-none"
|
||||
/>
|
||||
<p
|
||||
data-testid="ai-prompt-counter"
|
||||
aria-live="polite"
|
||||
class="text-right text-xs tabular-nums"
|
||||
:class="promptLength > PROMPT_MAX ? 'font-semibold text-destructive' : 'text-muted-foreground'"
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in a new issue