diff --git a/src/Rules/Password.php b/src/Rules/Password.php index 05783c43..296215cb 100644 --- a/src/Rules/Password.php +++ b/src/Rules/Password.php @@ -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; } diff --git a/tests/Rules/PasswordTest.php b/tests/Rules/PasswordTest.php index cbc83c34..e2faff7c 100644 --- a/tests/Rules/PasswordTest.php +++ b/tests/Rules/PasswordTest.php @@ -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();