SPasswordValidator is a password validator for the Yii framework. Tested with yii 1.1.12.
It's to use for a form/model validation rule.
-
Ready to use out of the box (see example basic below)
-
Presets to choose required strength (relax, normal, strong)
-
Customize parameters
- minimum number of characters
- minimum number of upper case characters
- minimum number of lower case characters
- minimum number of digits characters
- minimum number of special characters
-
Max parameter to avoid using another validator (in case you store value not encoded)
-
Documentation included
-
Coded using unit tests
public function rules()
{
return array(
array('password','ext.SPasswordValidator.SPasswordValidator');
);
}
public function rules()
{
return array(
array('password','ext.SPasswordValidator.SPasswordValidator', 'preset' => 'relax');
);
}
Number of upper case chars set to 1, minimum number of characters set to 10.
public function rules()
{
return array(
array('password','ext.SPasswordValidator.SPasswordValidator', 'up' => 1, 'min' => 10);
);
}
Preset strong plus a max length (in case you store something else that a password, not encrypted)
public function rules()
{
return array(
array('password','ext.SPasswordValidator.SPasswordValidator', 'preset' => 'strong', 'max' => 41);
);
}
Parameter other than max will be overriden by the preset parameters value.
Uncompress the archive in protected/extensions/
. So path to php file will be protected/extensions/SPasswordValidator/SPasswordValidator.php
.
Use to the fullapp branch to fork (include phpunit's unit tests)
This code is published under the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) licence.
The fullapp branch includes YiiDocumentor published under the GNU LESSER GENERAL PUBLIC LICENSE 3