Validates that the given password has reached the minimum strength required by the constraint. The strength is calculated by measuring the entropy of the password (in bits) based on its length and the number of unique characters.
PasswordStrength(
string $minStrength = 'medium',
?string $message = null
);Validator::passwordStrength()->validate('password'); // false
Validator::passwordStrength()->validate('i8Kq*MBob~2W"=p'); // true
Validator::passwordStrength(minStrength: 'very-strong')->validate('i8Kq*MBob~2W"=p'); // falseNote
An UnexpectedValueException will be thrown when a minStrength option is invalid.
Note
An UnexpectedValueException will be thrown when the input value is not a string.
type: string default: medium
Sets the minimum strength of the password in entropy bits. The entropy is calculated using the formula here.
Available options are:
weakentropy between64and79bits.mediumentropy between80and95bits.strongentropy between96and127bits.very-strongentropy greater than128bits.
All measurements less than 64 bits will fail.
type: ?string default: The password strength is not strong enough.
Message that will be shown when the password is not strong enough.
The following parameters are available:
| Parameter | Description |
|---|---|
{{ name }} |
Name of the invalid value |
{{ minStrength }} |
Selected minimum strength |
0.8.0Created