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.

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 16
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 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.

Parameters

mixed $callback

Return Value

Password|null

at line 143
static Password default()

Get the default configuration of the password rule.

Return Value

Password

at line 163
static Password required()

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

Return Value

Password

at line 175
static Password sometimes()

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

Return Value

Password

at line 187
ValidatorAwareRule setValidator(Validator $validator)

Set the performing validator.

Parameters

Validator $validator

Return Value

ValidatorAwareRule

at line 197
DataAwareRule setData(array $data)

Set the data under validation.

Parameters

array $data

Return Value

DataAwareRule

at line 207
static Password min(int $size)

Set the minimum size of the password.

Parameters

int $size

Return Value

Password

at line 215
Password max(int $size)

Set the maximum size of the password.

Parameters

int $size

Return Value

Password

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

Ensures the password has not been compromised in data leaks.

Parameters

int $threshold

Return Value

Password

at line 237
Password mixedCase()

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

Return Value

Password

at line 247
Password letters()

Makes the password require at least one letter.

Return Value

Password

at line 257
Password numbers()

Makes the password require at least one number.

Return Value

Password

at line 267
Password symbols()

Makes the password require at least one symbol.

Return Value

Password

at line 277
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 287
bool passes(string $attribute, mixed $value)

Determine if the validation rule passes.

Parameters

string $attribute
mixed $value

Return Value

bool

at line 345
array|string message()

Get the validation error message.

Return Value

array|string

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

Adds the given failures, and return false.

Parameters

array|string $messages

Return Value

bool

at line 363
array appliedRules()

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

Return Value

array

at line 381
Traversable getIterator()

Get an iterator for the password validation rules.

Return Value

Traversable

at line 396
static void flushState()

Flush all static state.

Return Value

void