<?php

namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class CheckTiersFourn implements ValidationRule
{
    /**
     * Run the validation rule.
     *
     * @param  \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString  $fail
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        $q = (mb_substr(trim($value),0,2) == 40 || mb_substr(trim($value),0,2) == 48)? true : false ;
        if(!$q){
            $fail('Compte Fournisseur incorrect ');
        }
    }
}
