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 int $max

The maximum 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 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 string|array|callable|null $defaultCallback

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

Methods

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

Apply the callback if the given "value" is (or resolves to) truthy.

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

Apply the callback if the given "value" is (or resolves to) 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)

Set the minimum size of the password.

$this
max(int $size)

Set the maximum 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.

$this
rules(Closure|string|array $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.

string|array
message()

Get the validation error message.

bool
fail(array|string $messages)

Adds the given failures, and return false.

Details

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

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

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

Return Value

$this|TWhenReturnType

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

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

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

Return Value

$this|TUnlessReturnType

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)

Set the minimum size of the password.

Parameters

int $size

Return Value

$this

$this max(int $size)

Set the maximum 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

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

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

Parameters

Closure|string|array $rules

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