class Password implements Rule, DataAwareRule, ValidatorAwareRule (View source)

Traits

Properties

protected Validator $validator

The validator performing the validation.

protected array $data

The data under validation.

protected int $min

The minimum size of the password.

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 has not been compromised in data leaks.

protected int $compromisedThreshold

The number of times a password can appear in data leaks before being consider compromised.

protected array $messages

The failure messages, if any.

static string|array|callable|null $defaultCallback

The callback that will generate the "default" version of the password rule.

Methods

$this|mixed
when(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is truthy.

$this|mixed
unless(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is falsy.

void
__construct(int $min)

Create a new rule instance.

static Password|null
defaults(Password|callable|null $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 array
required()

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

static array
sometimes()

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

$this
setValidator(Validator $validator)

Set the performing validator.

$this
setData(array $data)

Set the data under validation.

static $this
min(int $size)

Sets the minimum size of the password.

$this
uncompromised(int $threshold = 0)

Ensures the password has not been compromised in data leaks.

$this
mixedCase()

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

$this
letters()

Makes the password require at least one letter.

$this
numbers()

Makes the password require at least one number.

$this
symbols()

Makes the password require at least one symbol.

bool
passes(string $attribute, mixed $value)

Determine if the validation rule passes.

string|array
message()

Get the validation error message.

bool
fail(array|string $messages)

Adds the given failures, and return false.

Details

$this|mixed when(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is truthy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

$this|mixed unless(mixed $value, callable $callback, callable|null $default = null)

Apply the callback if the given "value" is falsy.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

$this|mixed

void __construct(int $min)

Create a new rule instance.

Parameters

int $min

Return Value

void

static Password|null defaults(Password|callable|null $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.

Parameters

Password|callable|null $callback

Return Value

Password|null

static Password default()

Get the default configuration of the password rule.

Return Value

Password

static array required()

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

Return Value

array

static array sometimes()

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

Return Value

array

$this setValidator(Validator $validator)

Set the performing validator.

Parameters

Validator $validator

Return Value

$this

$this setData(array $data)

Set the data under validation.

Parameters

array $data

Return Value

$this

static $this min(int $size)

Sets the minimum size of the password.

Parameters

int $size

Return Value

$this

$this uncompromised(int $threshold = 0)

Ensures the password has not been compromised in data leaks.

Parameters

int $threshold

Return Value

$this

$this mixedCase()

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

Return Value

$this

$this letters()

Makes the password require at least one letter.

Return Value

$this

$this numbers()

Makes the password require at least one number.

Return Value

$this

$this symbols()

Makes the password require at least one symbol.

Return Value

$this

bool passes(string $attribute, mixed $value)

Determine if the validation rule passes.

Parameters

string $attribute
mixed $value

Return Value

bool

string|array message()

Get the validation error message.

Return Value

string|array

protected bool fail(array|string $messages)

Adds the given failures, and return false.

Parameters

array|string $messages

Return Value

bool