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

ValidatorInterface::validate($formType) stopped working with symfony/form:4.2.3 #30601

Closed
Loupax opened this issue Mar 19, 2019 · 4 comments
Closed

Comments

@Loupax
Copy link

Loupax commented Mar 19, 2019

Symfony version(s) affected: 4.2.*

Description
After updating the form component to version 4.2.3, the method ValidatorInterface::validate($formType) stopped returning any violations when it contains an invalid value object.

How to reproduce
This is the common code between the two versions
https://github.com/Loupax/broken_validation/blob/master/src/Controller/DefaultController.php
Please note how we don't actually submit the form. This is done on purpose.

You can switch between the following branches for a working an broken example
https://github.com/Loupax/broken_validation/blob/working_example/composer.json#L14
https://github.com/Loupax/broken_validation/blob/broken_example/composer.json#L14

@xabbuh
Copy link
Member

xabbuh commented Mar 19, 2019

The previous behaviour was a bug that was fixed in #30265 (see the many referenced bug reports there for more details). I don't think there is anything we can do about it.

Maybe you can describe your use case and we can think about alternative solutions to your problem.

@Loupax
Copy link
Author

Loupax commented Mar 19, 2019

This came up because I keep my validation constraints inside my form types and came up with a case where I need to validate my data without having an HTTP request at hand.

As long as that's expected behavior, I'll try calling $form->submit() for my data and keep working from there

@xabbuh
Copy link
Member

xabbuh commented Mar 19, 2019

For that use case I would probably rather move the constraints to your underlying model because that's the data you seem to want to validate. Validating a form only makes sense if there are submitted data (and then I would only add constraints to form fields that are not mapped to the model).

@Loupax
Copy link
Author

Loupax commented Mar 19, 2019

Closing since this is confirmed not to be a bug

@Loupax Loupax closed this as completed Mar 19, 2019
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

3 participants