<?php

namespace App\Http\Requests\Push;

use App\Models\PushDeviceToken;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class RegisterTokenRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'token' => ['required', 'string', 'min:10'],
            'platform' => [
                'required',
                'string',
                Rule::in([
                    PushDeviceToken::PLATFORM_IOS,
                    PushDeviceToken::PLATFORM_ANDROID,
                    PushDeviceToken::PLATFORM_WEB,
                ]),
            ],
            'device_name' => ['nullable', 'string', 'max:255'],
            'app_version' => ['nullable', 'string', 'max:50'],
        ];
    }

    public function messages(): array
    {
        return [
            'token.required' => __('error.push.token_required'),
            'token.min' => __('error.push.token_invalid'),
            'platform.required' => __('error.push.platform_required'),
            'platform.in' => __('error.push.platform_invalid'),
        ];
    }
}
