Skip to content

Unable to have optional password validation #4

@rolebi

Description

@rolebi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions