<?php

declare(strict_types=1);

namespace App\Http\Requests\NovaCards;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AdminStoreNovaCardAssetPackRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'slug' => ['required', 'string', 'max:140', 'regex:/^[a-z0-9]+(?:-[a-z0-9]+)*$/'],
            'name' => ['required', 'string', 'max:120'],
            'description' => ['nullable', 'string', 'max:500'],
            'type' => ['required', Rule::in(['asset', 'template'])],
            'preview_image' => ['nullable', 'string', 'max:255'],
            'manifest_json' => ['nullable', 'array'],
            'official' => ['sometimes', 'boolean'],
            'active' => ['sometimes', 'boolean'],
            'order_num' => ['sometimes', 'integer', 'min:0', 'max:9999'],
        ];
    }
}