34 lines
1.4 KiB
PHP
34 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\NovaCards;
|
|
|
|
use App\Models\NovaCard;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreNovaCardDraftRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => ['nullable', 'string', 'min:2', 'max:' . (int) config('nova_cards.validation.title_max', 120)],
|
|
'quote_text' => ['nullable', 'string', 'min:' . (int) config('nova_cards.validation.quote_min', 3), 'max:' . (int) config('nova_cards.validation.quote_max', 420)],
|
|
'quote_author' => ['nullable', 'string', 'max:160'],
|
|
'quote_source' => ['nullable', 'string', 'max:180'],
|
|
'description' => ['nullable', 'string', 'max:' . (int) config('nova_cards.validation.description_max', 500)],
|
|
'format' => ['nullable', Rule::in(array_keys((array) config('nova_cards.formats', [])))],
|
|
'template_id' => ['nullable', 'integer', 'exists:nova_card_templates,id'],
|
|
'category_id' => ['nullable', 'integer', 'exists:nova_card_categories,id'],
|
|
'background_type' => ['nullable', Rule::in(['gradient', 'upload', 'template', 'solid'])],
|
|
'tags' => ['nullable', 'array', 'max:' . (int) config('nova_cards.validation.max_tags', 8)],
|
|
'tags.*' => ['string', 'min:2', 'max:32'],
|
|
];
|
|
}
|
|
} |