#37560 closed enhancement (fixed)
Enable sanitize_callback to return WP_Error
Reported by: | websupporter | Owned by: | rachelbaker |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | REST API | Keywords: | has-patch |
Focuses: | Cc: |
Description
As discussed in Slack, it might be helpful, if the sanitization callback could return a WP_Error
object like the validation callback.
https://wordpress.slack.com/archives/core-restapi/p1470200720000471
This patch wants to get this done.
With this patch, we would give developers the opportunity to reject incoming data without using the validation callback. It also enables us to do sanitization and validation in one function in instances where this could be useful.
I've oriented the solution on how it is done in the validation callback:
So, first all Errors are collected and then they will be returned. So if a request has more than one error, you get all the messages at once.
Attachments (2)
Change History (8)
This ticket was mentioned in Slack in #core-restapi by rachelbaker. View the logs.
8 years ago
#2
@
8 years ago
- Milestone changed from Awaiting Review to 4.7
- Owner set to rachelbaker
- Status changed from new to assigned
#3
@
8 years ago
- Keywords has-patch added
- Version set to 4.4
Updated the patch and added a unit test to check it's working as expected.
Updated patch with tests