All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 26h10m46s
22 lines
598 B
PHP
22 lines
598 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class ValidCaptcha implements ValidationRule
|
|
{
|
|
public function __construct(private readonly string $sessionKey = 'captcha_answer') {}
|
|
|
|
/**
|
|
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (trim((string) $value) !== (string) session($this->sessionKey)) {
|
|
$fail('Le code de vérification est incorrect.');
|
|
}
|
|
}
|
|
}
|