How to stop validation on constraint failure in Symfony2

夙愿已清 提交于 2020-01-03 08:58:27

问题


If I have many validators against my entity, can I somehow specify one that it stops the rest if it fails? IE: there's no point checking Permissions if it fails NotBlank.

Alternatively, if its not built in, perhaps theres a way to signal the graph walker to stop, and I can put in a validator that checks for prior failures and stops propagation through the graph.


回答1:


If you set the validation in ./app/config/validation.yml then SF2 will validate as the order of validations in the file. Once a validation is failed, it ignore the others.



来源:https://stackoverflow.com/questions/10135345/how-to-stop-validation-on-constraint-failure-in-symfony2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!