PasswordStrengthBundle icon indicating copy to clipboard operation
PasswordStrengthBundle copied to clipboard

Unable to have optional password validation

Open rolebi opened this issue 11 years ago • 0 comments

Hello there,

Bafford\PasswordStrengthBundle\Validator\Constraints\PasswordStrengthValidator don't ignore empty values :

public function validate($value, Constraint $constraint)
    {
        if($value === null)
            $value = '';
        // ...

instead of

public function validate($value, Constraint $constraint)
    {
        if(null === $value || '' === $value) {
            return;
        }
        // ...

Because of that it is not possible to have an optional password validation (in my case if the password is not present, then it will be autogenerated afterward).

Validation of emptyness should be left to the Symfony\Component\Validator\Constraints\NotBlank constraint.

I am aware that this change will cause a BC break, but it will be great to see this implementation in a new release.

rolebi avatar Feb 11 '14 10:02 rolebi