mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
29 lines
607 B
PHP
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.');
|
|
}
|
|
}
|
|
}
|