<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserAppsValidateCodeRequest extends FormRequest
{
    public function rules(): array
    {
        $rules = [
            'code' => 'required',
        ];

        if ($this->has('email')) {
            $rules['email'] = 'required|email';
        }

        if (! $this->has('phone')) {
            $rules['phone'] = 'required|string|max:20';
        }

        return $rules;
    }
}
