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.
Despite this being quite old, as of 5.1 there is a way to do this by using the Sequentially
constraint.
This constraint allows you to apply a set of rules that should be validated step-by-step, allowing to interrupt the validation once the first violation is raised.
You would just pass an array of the constraints to validate:
/**
* @Assert\Sequentially({ @Assert\NotBlank(), @Permissions() })
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With