Files
roxane/app/Rules/ValidCaptcha.php
Nebulae c848a8b47f
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 26h10m46s
feat(Contact & membership forms update with their notification)
2026-04-07 18:06:20 +02:00

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.');
}
}
}