neoban/backend/app/Http/Requests/GeneratePostRequest.php
kushal-saha 8e2ced8bed Implement new JSON:API Resource for the api responses.
Implement Authentication States, show logout options in auth store and services.
Make DB and controllers to make messages grouped by chats.
Refactor backend code to use DTO.
2026-04-28 12:38:46 +00:00

32 lines
755 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class GeneratePostRequest extends FormRequest
{
public function rules(): array
{
return [
'prompt' => [
'required',
'string',
'min:3',
function (string $attribute, mixed $value, \Closure $fail): void {
$wordCount = str_word_count(strip_tags(trim($value)));
if ($wordCount > 400) {
$fail("The {$attribute} must not exceed 400 words (you provided {$wordCount} words).");
}
},
],
];
}
public function authorize(): bool
{
return true;
}
}