PasswordValidator('The description of my validator, displayed when choosing a password'); } function validate($pwd) { //Check that the $pwd is valid ... return false || true; } } */ /* Below is your strategy used to validate the passwords. Feel free to (un)comment the following lines to feed your needs. Do not forget to add your custom validators. */ $password_strategy->add(new PasswordRegexpValidator('/.{8,}/', 'The password must contains at least 8 characters.')); //$password_strategy->add(new PasswordRegexpValidator('/[^a-zA-Z0-9]{2,}/', 'The password must contains at least 2 special characters.')); //$password_strategy->add(new PasswordRegexpValidator('/[a-z]{1,}/', 'The password must contains a lowercase letter.')); //$password_strategy->add(new PasswordRegexpValidator('/[A-Z]{1,}/', 'The password must contains an uppercase letter.')); $password_strategy->add(new PasswordRegexpValidator('/[0-9]{1,}/', 'The password must contains a number.')); //$password_strategy->add(new MyPasswordValidator()); ?>