trypost/app/Http/Requests/App/Workspace/StoreWorkspaceRequest.php
2026-06-30 14:17:30 +03:00

47 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Requests\App\Workspace;
use App\Enums\Workspace\BrandFont;
use App\Enums\Workspace\BrandVoiceTrait;
use App\Enums\Workspace\ImageStyle;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StoreWorkspaceRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$hex = ['nullable', 'string', 'regex:/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/'];
return [
'name' => ['required', 'string', 'max:255'],
'brand_website' => ['nullable', 'url', 'max:255'],
'brand_description' => ['nullable', 'string', 'max:2000'],
'brand_voice_traits' => ['nullable', 'array'],
'brand_voice_traits.*' => ['string', Rule::enum(BrandVoiceTrait::class)],
'brand_color' => $hex,
'background_color' => $hex,
'text_color' => $hex,
'brand_font' => ['sometimes', 'string', Rule::in(BrandFont::values())],
'image_style' => ['sometimes', 'string', Rule::in(ImageStyle::values())],
'content_language' => ['nullable', 'string', 'in:en,pt-BR,es,fr,de,it,nl,pl,el,ja,ko,zh,ru,tr,ar'],
'logo_url' => ['nullable', 'url', 'max:1024'],
];
}
public function messages(): array
{
return [
'name.required' => 'O nome do workspace é obrigatório.',
'name.max' => 'O nome do workspace deve ter no máximo 255 caracteres.',
];
}
}