Skip to content

Commit

Permalink
fix: unnecessary required rule hides real validation message
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Aug 15, 2023
1 parent c1e4ec3 commit 96952b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Listeners/AddValidatorRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __invoke(AbstractValidator $flarumValidator, Validator $validato

$validator->addExtension(
'turnstile',
function ($attribute, $value, $parameters) use ($secret) {
function ($attribute, $value) use ($secret) {
if (! is_string($value) || ! is_string($secret)) {
return false;
}
Expand All @@ -50,13 +50,13 @@ function ($attribute, $value, $parameters) use ($secret) {

if ($flarumValidator instanceof LogInValidator && $this->settings->get('blomstra-turnstile.signin')) {
$validator->addRules([
'turnstileToken' => ['required', 'turnstile'],
'turnstileToken' => ['turnstile'],
]);
}

if ($flarumValidator instanceof ForgotPasswordValidator && $this->settings->get('blomstra-turnstile.forgot')) {
$validator->addRules([
'turnstileToken' => ['required', 'turnstile'],
'turnstileToken' => ['turnstile'],
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Turnstile/Turnstile.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(string $secretKey)
* array this returns.
*
* @param string $response
* @return void
* @return array
*/
public function verify(string $response)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/TurnstileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class TurnstileValidator extends AbstractValidator
* {@inheritdoc}
*/
protected $rules = [
'turnstile' => ['required', 'turnstile'],
'turnstile' => ['turnstile'],
];
}

0 comments on commit 96952b4

Please sign in to comment.