Skip to content

Commit

Permalink
fixer
Browse files Browse the repository at this point in the history
 Password recovery: The Country field is required
  • Loading branch information
Litalino committed Jan 27, 2024
1 parent f35b948 commit 9f8fd0b
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/CountryFlagValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,20 @@ public function __construct(
protected TranslatorInterface $translator,
protected SettingsRepositoryInterface $settings
) {

}

public function __invoke(UserValidator $flarumValidator, Validator $validator): void
{
$rules = $validator->getRules();

$isRequired = $this->settings->get('justoverclock-country-flags.required')
&& $this->settings->get('justoverclock-country-flags.set_on_registration');

if ($isRequired && ! $flarumValidator->getUser()) {
$set_isRequired = 'required'; //|not_in:0
} else {
$set_isRequired = 'nullable';
}

//$rules['countryCode'] = [
//'nullable',
//Rule::requiredIf($isRequired && ! $flarumValidator->getUser()),
//$set_isRequired
//];
//$rules = [
// 'countryCode' => 'required', //, 'integer'
//];

$rules['countryCode'] = [
//'countryCode' => ['required']
'countryCode' => [$set_isRequired]
//$set_isRequired
//Rule::requiredIf($isRequired && ! $flarumValidator->getUser()),
'sometimes',
Rule::when($isRequired && ! $flarumValidator->getUser(), 'required', 'nullable'),

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.4

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.4

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.0

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.0

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.1

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.1

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.2

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.2

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Result of && is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.0

Negated boolean expression is always false.

Check failure on line 39 in src/CountryFlagValidation.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.0

Result of && is always false.
];

$validator->setRules($rules);
Expand Down

0 comments on commit 9f8fd0b

Please sign in to comment.