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.
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 16
void
__clone()
Clone the nested executable rule objects.
at line 109
__construct(int $min)
Create a new rule instance.
at line 125
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 143
static Password
default()
Get the default configuration of the password rule.
at line 163
static Password
required()
Get the default configuration of the password rule and mark the field as required.
at line 175
static Password
sometimes()
Get the default configuration of the password rule and mark the field as sometimes being required.
at line 187
ValidatorAwareRule
setValidator(Validator $validator)
Set the performing validator.
at line 197
DataAwareRule
setData(array $data)
Set the data under validation.
at line 207
static Password
min(int $size)
Set the minimum size of the password.
at line 215
Password
max(int $size)
Set the maximum size of the password.
at line 225
Password
uncompromised(int $threshold = 0)
Ensures the password has not been compromised in data leaks.
at line 237
Password
mixedCase()
Makes the password require at least one uppercase and one lowercase letter.
at line 247
Password
letters()
Makes the password require at least one letter.
at line 257
Password
numbers()
Makes the password require at least one number.
at line 267
Password
symbols()
Makes the password require at least one symbol.
at line 277
Password
rules(array|Closure|Rule|string $rules)
Specify additional validation rules that should be merged with the default rules during validation.
at line 287
bool
passes(string $attribute, mixed $value)
Determine if the validation rule passes.
at line 345
array|string
message()
Get the validation error message.
at line 353
protected bool
fail(array|string $messages)
Adds the given failures, and return false.
at line 363
array
appliedRules()
Get information about the current state of the password validation rules.
at line 381
Traversable
getIterator()
Get an iterator for the password validation rules.
at line 396
static void
flushState()
Flush all static state.