Files
newznab-tmux-NNTmux/app/Rules/TurnstileRule.php
T
2026-02-26 14:26:07 +01:00

29 lines
607 B
PHP

<?php
declare(strict_types=1);
namespace App\Rules;
use App\Services\TurnstileService;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class TurnstileRule implements ValidationRule
{
/**
* Run the validation rule.
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (empty($value)) {
$fail('Please complete the captcha verification.');
return;
}
if (! TurnstileService::verify($value)) {
$fail('The captcha verification failed. Please try again.');
}
}
}