Symfony-2 gives more than one validation error message

Provided by my validation.yml:

    task:
        - Email: 
               message: The email "{{ value }}" is not a valid email.
        - MinLength: { limit: 50, message: You must be 50 or under to enter. }

My problem is that if I give the "wrong email address" in the task field, it gives two error messages:

The email "wrong-email" is not a valid email.
You must be 50 or under to enter.

In fact, I want to show only one error message at a time. This means that he should only check the "MinLength" check if it is a valid email address.

+5
source share
1 answer

The verification sequence may be performed using group sequences. I fixed group sequences for the YAML driver only today, so you may need to wait for the next version 2.0 or the main branch.

MyEntity:
    group_sequence: [MyEntity, Extra]
    properties:
        task:
            - Email: { message: ... }
            - MinLength { limit: 50, message: ..., groups: Extra }

"" , "MyEntity" (.. ) .

+6

All Articles