如何在 sylius 上自定义密码验证器?

How can I custom password validator on sylius?

我想自定义用户密码验证器。我测试了这个:

http://sylius-try.readthedocs.io/en/latest/bundles/general/overriding_validation.html

http://sylius-older.readthedocs.io/en/latest/customization/validation.html

http://docs.sylius.org/en/latest/customization/validation.html

但是它对 me.This 不起作用是我的代码:

#AppBundle/Resources/config/validation.yml

Sylius\Bundle\UserBundle\Form\Model\ChangePassword:
    properties:
        currentPassword:
            - Symfony\Component\Security\Core\Validator\Constraints\UserPassword:
                message: sylius.user.plainPassword.wrong_current
                groups: [myGroup]
        newPassword:
            - Regex:
                pattern: ((?=\S*?[A-Z])(?=\S*?[a-z]).{8,})
                message: myGroup.user.password.regex
                groups: [myGroup]

配置:

#app/config/config.yml   
 imports:
    - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }

Services.yml :

# app/config/services.yml
parameters:
    sylius.form.type.user_change_password: [myGroup]
    sylius.form.type.user_reset_password.validation_groups: [myGroup] # the product class also needs to be aware of the translation'a validation

问题是当我尝试更改密码或注册时,未检测到正则表达式。我确信它有效,因为当我更改文件 ChangePassword.yml 时,一切正常。但是我不能接触供应商的文件。

感谢您的宝贵时间

我找到了解决办法。我用 [sylius] 替换了 [myGroup]。

在教程中说要自定义名称,但是当我这样做时却没有用。所以我想我们必须把 [sylius]