Craft 3 Class Reference

Class craft\validators\UserPasswordValidator

Inheritance
craft\validators\UserPasswordValidator » yii\validators\StringValidator » yii\validators\Validator » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Available since version
3.0
Source Code
https://github.com/craftcms/cms/blob/master/src/validators/UserPasswordValidator.php

Class UserPasswordValidator.

Public Properties
Property Type Description Defined By
$attributes array, string Attributes to be validated by this validator. yii\validators\Validator
$builtInValidators array List of built-in validators (name => class or configuration) yii\validators\Validator
$currentPassword string, null The user's current (hashed) password. craft\validators\UserPasswordValidator
$enableClientValidation boolean Whether to enable client-side validation for this validator. yii\validators\Validator
$encoding string The encoding of the string value to be validated (e.g. 'UTF-8'). yii\validators\StringValidator
$except array, string Scenarios that the validator should not be applied to. yii\validators\Validator
$forceDifferent boolean Whether the password must be different from the existing password. craft\validators\UserPasswordValidator
$isEmpty callable A PHP callable that replaces the default implementation of isEmpty(). yii\validators\Validator
$length integer, array Specifies the length limit of the value to be validated. yii\validators\StringValidator
$max integer Maximum length. yii\validators\StringValidator
$message string User-defined error message used when the value is not a string. yii\validators\StringValidator
$min integer Minimum length. yii\validators\StringValidator
$notEqual string User-defined error message used when the length of the value is not equal to $length. yii\validators\StringValidator
$on array, string Scenarios that the validator can be applied to. yii\validators\Validator
$sameAsCurrent string, null User-defined error message used when the new password is the same as $currentPassword. craft\validators\UserPasswordValidator
$skipOnEmpty boolean Whether this validation rule should be skipped if the attribute value is null or an empty string. yii\validators\Validator
$skipOnError boolean Whether this validation rule should be skipped if the attribute being validated already has some validation error according to some previous rules. yii\validators\Validator
$tooLong string User-defined error message used when the length of the value is greater than $max. yii\validators\StringValidator
$tooShort string User-defined error message used when the length of the value is smaller than $min. yii\validators\StringValidator
$when callable A PHP callable whose return value determines whether this validator should be applied. yii\validators\Validator
$whenClient string A JavaScript function name whose return value determines whether this validator should be applied on the client-side. yii\validators\Validator
Public Methods
Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\BaseObject
__clone() This method is called after the object is created by cloning an existing one. yii\base\Component
__construct() Constructor. craft\validators\UserPasswordValidator
__get() Returns the value of an object property. yii\base\BaseObject
__isset() Checks if a property is set, i.e. defined and not null. yii\base\BaseObject
__set() Sets value of an object property. yii\base\BaseObject
__unset() Sets an object property to null. yii\base\BaseObject
addError() Adds an error about the specified attribute to the model object. yii\validators\Validator
attachBehavior() Attaches a behavior to this component. yii\base\Component
attachBehaviors() Attaches a list of behaviors to the component. yii\base\Component
behaviors() Returns a list of behaviors that this component should behave as. yii\base\Component
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
className() Returns the fully qualified name of this class. yii\base\BaseObject
clientValidateAttribute() {@inheritdoc} yii\validators\StringValidator
createValidator() Creates a validator object. yii\validators\Validator
detachBehavior() Detaches a behavior from the component. yii\base\Component
detachBehaviors() Detaches all behaviors from the component. yii\base\Component
ensureBehaviors() Makes sure that the behaviors declared in behaviors() are attached to this component. yii\base\Component
getAttributeNames() Returns cleaned attribute names without the ! character at the beginning. yii\validators\Validator
getBehavior() Returns the named behavior object. yii\base\Component
getBehaviors() Returns all behaviors attached to this component. yii\base\Component
getClientOptions() {@inheritdoc} yii\validators\StringValidator
hasEventHandlers() Returns a value indicating whether there is any handler attached to the named event. yii\base\Component
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() {@inheritdoc} craft\validators\UserPasswordValidator
isActive() Returns a value indicating whether the validator is active for the given scenario and attribute. yii\validators\Validator
isEmpty() Checks if the given value is empty. craft\validators\UserPasswordValidator
off() Detaches an existing event handler from this component. yii\base\Component
on() Attaches an event handler to an event. yii\base\Component
trigger() Triggers an event. yii\base\Component
validate() Validates a given value. yii\validators\Validator
validateAttribute() {@inheritdoc} craft\validators\UserPasswordValidator
validateAttributes() Validates the specified object. yii\validators\Validator
Protected Methods
Method Description Defined By
formatMessage() Formats a mesage using the I18N, or simple strtr if \Yii::$app is not available. yii\validators\Validator
validateValue() {@inheritdoc} yii\validators\StringValidator

Property Details

$currentPassword public property #

The user's current (hashed) password.

public string, null $currentPassword null

$forceDifferent public property #

Whether the password must be different from the existing password.

public boolean $forceDifferent false

$sameAsCurrent public property #

User-defined error message used when the new password is the same as $currentPassword.

public string, null $sameAsCurrent null

Method Details

__construct() public method #

Constructor.

The default implementation does two things:

If this method is overridden in a child class, it is recommended that

public void __construct ( array $config = [] )
$config array Name-value pairs that will be used to initialize the object properties

init() public method #

{@inheritdoc}

public void init ( )

isEmpty() public method #

Checks if the given value is empty.

A value is considered empty if it is null, an empty array, or an empty string. Note that this method is different from PHP empty(). It will return false when the value is 0.

public boolean isEmpty ( $value )
$value mixed The value to be checked
return boolean Whether the value is empty

validateAttribute() public method #

{@inheritdoc}

public void validateAttribute ( $model, $attribute )
$model
$attribute