Skip to content

[Constraints/Collection] Add missing : and ~ in the yaml code block #8587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2017
Merged

[Constraints/Collection] Add missing : and ~ in the yaml code block #8587

merged 1 commit into from
Nov 5, 2017

Conversation

NicolasDievart
Copy link
Contributor

There were some typos in the yaml code block, some missing : and ~

@xabbuh xabbuh added this to the 2.7 milestone Nov 3, 2017
@@ -223,7 +223,7 @@ you can do the following:
- Collection:
fields:
personal_email:
- Required
- Required:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this proposal the right fix?

Shouldn't this:

        - Collection:
            fields:
                personal_email:
                    - Required:
                        - NotBlank: ~
                        - Email: ~

be like this instead?

        - Collection:
            fields:
                personal_email:
                    - Required: ~
                    - NotBlank: ~
                    - Email: ~

Copy link
Contributor Author

@NicolasDievart NicolasDievart Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know about "Required" before (always used NotBlank), but I tried

- Required:
    - NotBlank: ~
    - Email: ~

And it works, and I based my guess also on the annotation code block

@Assert\Required({@Assert\NotBlank, @Assert\Email})

Which seems to be, for required, a combination of constraints

But according to this:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/Required.php

Your guess seems correct too, as it can be nested or a side by side constraint

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nesting is correct here. We do specify the constraints that are required for each collection entry.

@weaverryan
Copy link
Member

Thanks @NicolasDievart!

@weaverryan weaverryan merged commit 2778d33 into symfony:2.7 Nov 5, 2017
weaverryan added a commit that referenced this pull request Nov 5, 2017
…de block (NicolasDievart)

This PR was merged into the 2.7 branch.

Discussion
----------

[Constraints/Collection] Add missing : and ~ in the yaml code block

There were some typos in the yaml code block, some missing : and ~

Commits
-------

2778d33 Add missing : and ~ in the yaml code block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants