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

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.

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.

void
__clone()

Clone the nested executable rule objects.

__construct(int $min)

Create a new rule instance.

static Password|null
defaults(mixed $callback = null)

Set the default callback to be used for determining a password's default rules.

static Password
default()

Get the default configuration of the password rule.

static Password
required()

Get the default configuration of the password rule and mark the field as required.

static Password
sometimes()

Get the default configuration of the password rule and mark the field as sometimes being required.

setValidator(Validator $validator)

Set the performing validator.

setData(array $data)

Set the data under validation.

static Password
min(int $size)

Set the minimum size of the password.

max(int $size)

Set the maximum size of the password.

uncompromised(int $threshold = 0)

Ensures the password has not been compromised in data leaks.

mixedCase()

Makes the password require at least one uppercase and one lowercase letter.

letters()

Makes the password require at least one letter.

numbers()

Makes the password require at least one number.

symbols()

Makes the password require at least one symbol.

rules(array|Closure|Rule|string $rules)

Specify additional validation rules that should be merged with the default rules during validation.

bool
passes(string $attribute, mixed $value)

Determine if the validation rule passes.

array|string
message()

Get the validation error message.

bool
fail(array|string $messages)

Adds the given failures, and return false.

array
appliedRules()

Get information about the current state of the password validation rules.

string
toPasswordRulesString()

Convert the password rule to a passwordrules HTML attribute string.

getIterator()

Get an iterator for the password validation rules.

static void
flushState()

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

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.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in ClonesCustomRules at line 15
void __clone()

Clone the nested executable rule objects.

Return Value

void

at line 109
__construct(int $min)

Create a new rule instance.

Parameters

int $min

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.

Parameters

mixed $callback

Return Value

Password|null

Exceptions

InvalidArgumentException

at line 146
static Password default()

Get the default configuration of the password rule.

Return Value

Password

at line 166
static Password required()

Get the default configuration of the password rule and mark the field as required.

Return Value

Password

at line 178
static Password sometimes()

Get the default configuration of the password rule and mark the field as sometimes being required.

Return Value

Password

at line 190
ValidatorAwareRule setValidator(Validator $validator)

Set the performing validator.

Parameters

Validator $validator

Return Value

ValidatorAwareRule

at line 200
DataAwareRule setData(array $data)

Set the data under validation.

Parameters

array $data

Return Value

DataAwareRule

at line 210
static Password min(int $size)

Set the minimum size of the password.

Parameters

int $size

Return Value

Password

at line 218
Password max(int $size)

Set the maximum size of the password.

Parameters

int $size

Return Value

Password

at line 228
Password uncompromised(int $threshold = 0)

Ensures the password has not been compromised in data leaks.

Parameters

int $threshold

Return Value

Password

at line 240
Password mixedCase()

Makes the password require at least one uppercase and one lowercase letter.

Return Value

Password

at line 250
Password letters()

Makes the password require at least one letter.

Return Value

Password

at line 260
Password numbers()

Makes the password require at least one number.

Return Value

Password

at line 270
Password symbols()

Makes the password require at least one symbol.

Return Value

Password

at line 280
Password rules(array|Closure|Rule|string $rules)

Specify additional validation rules that should be merged with the default rules during validation.

Parameters

array|Closure|Rule|string $rules

Return Value

Password

at line 290
bool passes(string $attribute, mixed $value)

Determine if the validation rule passes.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 348
array|string message()

Get the validation error message.

Return Value

array|string

at line 356
protected bool fail(array|string $messages)

Adds the given failures, and return false.

Parameters

array|string $messages

Return Value

bool

at line 366
array appliedRules()

Get information about the current state of the password validation rules.

Return Value

array

at line 386
string toPasswordRulesString()

Convert the password rule to a passwordrules HTML attribute string.

Return Value

string

See also

https://developer.apple.com/password-rules/

at line 417
Traversable getIterator()

Get an iterator for the password validation rules.

Return Value

Traversable

at line 432
static void flushState()

Flush all static state.

Return Value

void