<?php

namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Symfony\Component\Mime\Message;

class NameRule implements ValidationRule
{
    /**
     * Run the validation rule.
     *
     * @param  \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        $rule = preg_match('/[$&+,:;=?@#|<>.^*()%!-]|[0-9]/' , $value);
        if($rule) {
           $fail('The name field format is invalid.');
        }
    }
}
