Symfony validation between 2 fields

I have a change password form with 3 fields:

and want to validate data that the newPassword does not equal the current one.

I can validate to check it’s not empty in my ChangePassword entity that the form uses, for example, using:

public static function loadValidatorMetadata(ClassMetadata $metadata)
    $metadata->addPropertyConstraint('newPassword', new NotBlank());

But how can I validate one field against another? Do I just need to hard code that and if so, where would that code best sit?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *