<?php

declare(strict_types=1);

namespace App\Base;

use Illuminate\Validation\Rule;

class ReadPageRequest extends AbstractRequest
{
    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return static::getRuleMapForPage();
    }

    /**
     * @return array<string, mixed[]>
     */
    public static function getRuleMapForPage(): array
    {
        $RuleMap = [
            'Page' => ['integer', 'min:1'],
            'PerPage' => ['integer', 'min:5', 'max:100'],
            'SortField' => ['string'],
            'SortOrder' => ['string', Rule::in([ReadPageParameter::SortAsc, ReadPageParameter::SortDesc])],
        ];
        foreach (static::getRuleMap() as $Key => $Item) {
            $RuleMap['Filter.'.$Key] = $Item;
        }

        return $RuleMap;
    }

    /**
     * @return array<string, string[]>
     */
    public static function getRuleMap(): array
    {
        return [
        ];
    }
}
