Yii 1.1: epasswordstrength

Validates password strength
12 followers

This validator checks if password is strong enough. Password is strong enough, if it have defined minimum number of characters(which can be changed), and if it contain at least one upper case letter, at least one lower case letter, and at least one number.

Requirements

Class is developed and tested using Yii version 1.1.7

Usage

Unzip the contents of the zip file onto your protected/extensions/validators folder, then edit rules method of the model class as following:

public function rules()
{ 
   return array(
     array(array('password','ext.validators.EPasswordStrength', 'min'=>7),
    );
 
}

Resources

Change Log

0.1

  • Initial release

Total 2 comments

#17639 report it
vihuarar at 2014/07/09 07:56pm
Bug with Internationalization

I found a bug in the line 31, because when I run the yiic message messagePath shows me an error...

the wrong line is: $message=$this->message!==null?$this->message:Yii::t("EPasswordStrength","{attribute} is weak. {attribute} must contain at least {$this->min} characters, at least one lower case letter, at least one upper case letter, and at least one number.");

and the fixed one: $message=$this->message!==null?$this->message:Yii::t("EPasswordStrength","{attribute} is weak. {attribute} must contain at least {min} characters, at least one lower case letter, at least one upper case letter, and at least one number.", array("{min}"=>$this->min));

this is the way you should pass the params.. Yii::t('app', 'Path alias "{alias}" is redefined.', array('{alias}'=>$alias))

according to: http://www.yiiframework.com/doc/guide/1.1/en/topics.i18n#internationalization

#9903 report it
Lothor at 2012/09/20 10:41am
Update Sample
public function rules()
{ 
   return array(
      array('password', 'ext.validators.EPasswordStrength', 'min' => 7, 'message' => Yii::t('category', 'Error Message')),
   );
 
}

Leave a comment

Please to leave your comment.

Create extension