Skip to content

Can't override validation in SF4 #2886

@sbruev

Description

@sbruev

So, I'm trying to make a custom validation group. I've decided to test it with simple alteration to the registration validation rule, by increasing the min length to 6 characters. Right now my configuration is following:

# config/packages/fos_user.yaml

fos_user:
  db_driver: orm # other valid values are 'mongodb' and 'couchdb'
  firewall_name: main
  user_class: App\Entity\User
  from_email:
    address: "%mailer_user%"
    sender_name: "%mailer_user%"
  registration:
    form:
      type: FOS\UserBundle\Form\Type\RegistrationFormType
      validation_groups:  [CustomValidation]
# config/packages/validator/validation.yaml

FOS\UserBundle\Model\User:
  properties:
    username:
      - NotBlank:
          groups: [CustomValidation]
      - Length:
          min: 6
          minMessage: fos_user.password.short
          groups: [CustomValidation]

I've checked that the FOSUser config has updated with dump:config. I've run cache:clear. Yet the FOSUser ignores my config and continue to use the standard validation rules for registration (i.e. 2 chars min).

What am I missing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions