<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;

class StoreTradingAccountRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'broker_name' => ['required', 'string', 'max:255'],
            'account_number' => ['nullable', 'string', 'max:255'],
            'account_type' => ['required', 'in:demo,live,prop'],
            'platform' => ['nullable', 'string', 'max:255'],
            'server' => ['nullable', 'string', 'max:255'],
            'currency' => ['required', 'string', 'size:3'],
            'leverage' => ['nullable', 'integer', 'min:1', 'max:10000'],
            'balance' => ['required', 'numeric', 'min:0'],
            'equity' => ['required', 'numeric', 'min:0'],
            'margin' => ['required', 'numeric', 'min:0'],
            'free_margin' => ['required', 'numeric', 'min:0'],
            'api_provider' => ['nullable', 'in:metaapi,broker_api'],
            'api_account_id' => ['nullable', 'string', 'max:255'],
        ];
    }
}
