crmCustomer = $crmCustomer; } /** * Run the validation rule. * * @param string $attribute * @param mixed $value * @param \Closure(string):\Illuminate\Translation\PotentiallyTranslatedString $fail * @return void * @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.Missing * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed */ public function validate(string $attribute, mixed $value, \Closure $fail): void { // phpcs:enable try { if (!Customer::login($this->crmCustomer->email, strval($value))) { $fail(trans('Votre ancien mot de passe n\'as pu être vérifié')); } } catch (ApiErrorException $e) { if ($e->getApiError()->equals(ApiError::authFailed)) { $fail($e->getMessage()); } else { throw $e; } } } }