Password
class Password implements DataAwareRule, ImplicitRule, IteratorAggregate, Rule, ValidatorAwareRule
Traits
Properties
| protected Validator|null | $validator | The validator performing the validation. |
|
| protected array | $data | The data under validation. |
|
| protected int | $min | The minimum size of the password. |
|
| protected int|null | $max | The maximum size of the password. |
|
| protected bool | $required | If the password is required. |
|
| protected bool | $sometimes | If the password should only be validated when present. |
|
| protected bool | $mixedCase | If the password requires at least one uppercase and one lowercase letter. |
|
| protected bool | $letters | If the password requires at least one letter. |
|
| protected bool | $numbers | If the password requires at least one number. |
|
| protected bool | $symbols | If the password requires at least one symbol. |
|
| protected bool | $uncompromised | If the password should not have been compromised in data leaks. |
|
| protected int | $compromisedThreshold | The number of times a password can appear in data leaks before being considered compromised. |
|
| protected array | $customRules | Additional validation rules that should be merged into the default rules during validation. |
|
| protected array | $messages | The failure messages, if any. |
|
| static null|array|callable|string | $defaultCallback | The callback that will generate the "default" version of the password rule. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Create a new rule instance.
Set the default callback to be used for determining a password's default rules.
Get the default configuration of the password rule and mark the field as required.
Get the default configuration of the password rule and mark the field as sometimes being required.
Set the data under validation.
Ensures the password has not been compromised in data leaks.
Determine if the validation rule passes.
Get the validation error message.
Adds the given failures, and return false.
Get information about the current state of the password validation rules.
Convert the password rule to a passwordrules HTML attribute string.
Get an iterator for the password validation rules.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
ClonesCustomRules at line 15
void
__clone()
Clone the nested executable rule objects.
at line 109
__construct(int $min)
Create a new rule instance.
at line 128
static Password|null
defaults(mixed $callback = null)
Set the default callback to be used for determining a password's default rules.
If no arguments are passed, the default password rule configuration will be returned.
Boot-only when setting. The default callback persists in a static property for the worker lifetime and is used by every Password::default() call across all coroutines.
at line 146
static Password
default()
Get the default configuration of the password rule.
at line 166
static Password
required()
Get the default configuration of the password rule and mark the field as required.
at line 178
static Password
sometimes()
Get the default configuration of the password rule and mark the field as sometimes being required.
at line 190
ValidatorAwareRule
setValidator(Validator $validator)
Set the performing validator.
at line 200
DataAwareRule
setData(array $data)
Set the data under validation.
at line 210
static Password
min(int $size)
Set the minimum size of the password.
at line 218
Password
max(int $size)
Set the maximum size of the password.
at line 228
Password
uncompromised(int $threshold = 0)
Ensures the password has not been compromised in data leaks.
at line 240
Password
mixedCase()
Makes the password require at least one uppercase and one lowercase letter.
at line 250
Password
letters()
Makes the password require at least one letter.
at line 260
Password
numbers()
Makes the password require at least one number.
at line 270
Password
symbols()
Makes the password require at least one symbol.
at line 280
Password
rules(array|Closure|Rule|string $rules)
Specify additional validation rules that should be merged with the default rules during validation.
at line 290
bool
passes(string $attribute, mixed $value)
Determine if the validation rule passes.
at line 348
array|string
message()
Get the validation error message.
at line 356
protected bool
fail(array|string $messages)
Adds the given failures, and return false.
at line 366
array
appliedRules()
Get information about the current state of the password validation rules.
at line 386
string
toPasswordRulesString()
Convert the password rule to a passwordrules HTML attribute string.
at line 417
Traversable
getIterator()
Get an iterator for the password validation rules.
at line 432
static void
flushState()
Flush all static state.