I\'m trying to put together a change password feature in Symfony2. I have a \"current password\" field, a \"new password\" field and a \"confirm new password\" field, and th
In Symfony 2.1 you can use the built-in validator: http://symfony.com/doc/master/reference/constraints/UserPassword.html
So for instance in your form builder:
// declare
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
// mapped=>false (new in 2.1) is to let the builder know this is not an entity field
->add('currentpassword', 'password', array('label'=>'Current password', 'mapped' => false, 'constraints' => new UserPassword()))
Apparently there's a bug right now with that validator so might or might now work https://github.com/symfony/symfony/issues/5460