Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
fix: handle null values on the password validator (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsobries authored Mar 24, 2021
1 parent 70ce1ab commit db2fe55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Rules/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Password extends Fortify
*/
public function passes($attribute, $value)
{
// Handle potential NULL values
$value = $value ?: '';

if ($this->needsLowercase($value)) {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/Rules/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use ARKEcosystem\Fortify\Rules\Password;

it('handle null values', function () {
$rule = (new Password())->requireUppercase()->requireNumeric()->requireSpecialCharacter();

expect($rule->passes('password', null))->toBeFalse();
});

it('can check for lowercase requirements', function () {
$rule = (new Password())->requireLowercase();

Expand Down

0 comments on commit db2fe55

Please sign in to comment.