FOSUserBundle密码验证

Mad*_*nty 9 symfony fosuserbundle

我正在尝试覆盖FOSUserBundle中当前的密码验证.我尝试了一些选项,但我仍然找不到解决方案.

为了增加密码的MinLength,我创建了一个validation.yml:

# src/Acme/UserBundle/Resources/config/validation.yml
Acme\UserBundle\Entity\User:
    properties:
        username:
            - MinLength: { limit: 3, message: "Your username must have at least {{ limit }} characters." }
            - MaxLength: { limit: 255, message: "The username is too long" }
            - NotBlank: { message: "Please enter a username"}       

        plainPassword:
            - NotBlank: { message: "Please enter a password"}
            - MinLength: { limit: 8, message: "Your password must have at least {{ limit }} characters.", groups [Registration,Profile]}
                - MaxLength: { limit: 255, message: "The password is too long" }

Acme\UserBundle\Form\Model\ChangePassword:
  properties:  
      new:
          - NotBlank: { message: "Please enter a new password", groups [ChangePassword]}
          - MinLength: { limit: 8, message: "Your password must have at least {{ limit }} characters.", groups [ChangePassword]}
          - MaxLength: { limit: 255, message: "The password is too long", groups [ChangePassword]}  

Acme\UserBundle\Form\Model\ResetPassword:
        new:
            - NotBlank: { message: "Please enter a new password", groups [ResetPassword]}
            - MinLength: { limit: 8, message: "Your new password must have at least {{ limit }} characters.", groups [ResetPassword]}
            - MaxLength: { limit: 255, message: "The new password is too long", groups [ResetPassword]}
Run Code Online (Sandbox Code Playgroud)

这对我来说很合适/register,但是在/change-passwordFOSUserBundle的默认最小长度验证中取得了所有权.

为了更清楚地说明我的问题,在FOSUserBundle中为密码设置MinLength以确保它在任何地方都经过验证的正确方法是什么?

另外,使用FOSUserBundle在ChangePassword中进行验证的正确方法是oldpassword != newpassword什么?