<?php

namespace Openguru\OpenCartFramework\Validator\ValidationRules;

use Closure;

class Email implements ValidationRuleInterface
{
    public function validate(string $field, array $input, Closure $fail): void
    {
        $email = $input[$field] ?? '';

        if ($email && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $fail('Email is not valid');
        }
    }
}
