Skip to content
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

[Validator] Inform developer if componant is missing #37012

Closed
Seb33300 opened this issue May 30, 2020 · 7 comments
Closed

[Validator] Inform developer if componant is missing #37012

Seb33300 opened this issue May 30, 2020 · 7 comments

Comments

@Seb33300
Copy link
Contributor

Seb33300 commented May 30, 2020

Symfony version(s) affected: 5.0.8

Description
I started a new Symfony 5 project and I wanted to enable the automatic validation feature in my validator config file:

framework:
    validation:
        # Enables validator auto-mapping support.
        # For instance, basic validation constraints will be inferred from Doctrine's metadata.
        auto_mapping:
            App\Entity\: []

But automatic validation was not working after that.
This was because as mentioned in the blog post, this feature require PropertyInfo component to work.

Maybe we should trigger an exception to informed the developer if this option is enabled but the component is not installed?

@xabbuh
Copy link
Member

xabbuh commented May 31, 2020

I don't think that would be correct either since mapping constraints based on Doctrine metadata would work as expected.

@Seb33300
Copy link
Contributor Author

Seb33300 commented Jun 1, 2020

I am not sure to understand what you mean.

Automatic validation was not working as expected for me until I manually added the PropertyInfo component.

@xabbuh
Copy link
Member

xabbuh commented Jun 1, 2020

Can you debug what the DoctrineLoader does in your case? I don't see how it requires the PropertyInfo component to be present.

@Seb33300
Copy link
Contributor Author

Seb33300 commented Jun 2, 2020

In the PR related to this feature: #27735

This feature automatically adds some validation constraints by inferring existing metadata. To do so, it uses the PropertyInfo component and Doctrine metadata

Maybe @dunglas can give more details?

@dunglas
Copy link
Member

dunglas commented Jun 2, 2020

Actually you need PropertyInfo to extract some constraints from Doctrine metadata. But throwing an error if PropertyInfo isn’t installed is a bit harsh because you can also register your own guessers, without needing PropertyInfo.

@xabbuh
Copy link
Member

xabbuh commented Jun 2, 2020

There are two different loaders: The DoctrineLoader and the PropertyInfoLoader. The former one should work without the PropertyInfo component. That's why I was asking if you could please debug why it is not doing anything in your case.

@xabbuh
Copy link
Member

xabbuh commented Jun 8, 2020

I am going to close here for now due to the lack of feedback. Please let us know when you have more information and we can consider to reopen.

@xabbuh xabbuh closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants