Validation on DELETE action
See original GitHub issueIt looks like validation on DELETE action has been explicitly prevented in ValidateListener::onKernelView()
//src\Validator\EventListener\ValidateListener.php::onKernelView()
if (
$controllerResult instanceof Response
|| $request->isMethodSafe()
|| $request->isMethod('DELETE') //<========================== here, why so much hate?
|| !($attributes = RequestAttributesExtractor::extractAttributes($request))
|| !$attributes['receive']
|| $this->isOperationAttributeDisabled($attributes, self::OPERATION_ATTRIBUTE_KEY)
) {
return;
}
However validation is very useful to enforce some business logic on the action itself (and share its behavior with the regular controller form view and the api platform). Would it be possible to let validation occurs on DELETE action? Alternatively add a parameter to enable it?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Validation Rule On Delete - Salesforce Developer Community
Just want to know that is there any way to fire validation rule on any record delete (Only on delete). I don't want...
Read more >Api-Platform: use validation_groups on DELETE action
Here is the solution we used to solve this hard-coded behavior in ApiPlatform by reversing it in an event subscriber:
Read more >Validation rule on delete action button in Datagrid
I would like to created validation rule on the delete action button. It cannot delete data in the grid if the selected date...
Read more >Understand validations on record deletion | Zoho Creator Help
The Validations on record deletion action will executed when you try to delete a record in the form.
Read more >Validation-OnDelete Not Getting Trigerred When Clicking on ...
The Validation-OnDelete event runs in the Buffer, it's not trigerred until a Save action get trigerred. When you click on the Trash button,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The current recommendation would be to use DataPersister https://api-platform.com/docs/core/data-persisters/
Thanks for sharing your workaround. It’s working great, however it means duplicating this code for every delete actions. We tried to solve this hard-coded behavior by reversing it in an event subscriber:
With that in place, validation is working as expected whenever “validation_groups” is explicitly defined on the “delete” item operation without other extra code. Does it make sense?