我试图以这种方式覆盖 FOSUserBundle 的密码约束:
XXX/XXXBundle/Resources/config/validation.yml
XXX\XXXBundle\Entity\User:
properties:
username:
- NotBlank: ~
email:
- NotBlank: ~
- Email: { groups: [online] }
plainPassword:
- MinLength: { limit: 6, message: "Your pw must have at least {{ limit }} characters.", groups: [Registration, Profile, ResetPassword, ChangePassword] }
- Regex: { pattern: "/(?=.*[A-Za-z])(?=.*[0-9])[A-Za-z0-9]+/", message: "Das Passwort muss eine Ziffer und Buchstaben enthalten.", groups: [Registration, Profile, ResetPassword, ChangePassword] }
这对我不起作用。当我尝试更改密码时,接受 2 个字符。我已经尝试过使用和不使用验证组 - 没有变化。
有任何想法吗?