Password
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 | $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
Apply the callback if the given "value" is truthy.
Apply the callback if the given "value" is falsy.
Create a new rule instance.
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.
Sets the minimum size of the password.
Ensures the password has not been compromised in data leaks.
Makes the password require at least one uppercase and one lowercase letter.
Makes the password require at least one letter.
Makes the password require at least one number.
Makes the password require at least one symbol.
Specify additional validation rules that should be merged with the default rules during validation.
Determine if the validation rule passes.
Get the validation error message.
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.
$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.
If no arguments are passed, the default password rule configuration will be returned.
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.
$this
rules(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.
protected bool
fail(array|string $messages)
Adds the given failures, and return false.