<?php

namespace App\Http\Requests;

use App\Core\Request;
use App\Exceptions\ValidationException;

class LoginRequest
{
    public static function validate(Request $request): array
    {
        $data = $request->json();
        if (empty($data['email']) || empty($data['password'])) {
            throw new ValidationException('Email and password are required');
        }

        if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
            throw new ValidationException('Invalid email format', ['field' => 'email']);
        }

        return $data;
    }
}
