[wp-trac] [WordPress Trac] #51255: REST API: Support request level validation

WordPress Trac noreply at wordpress.org
Sat Sep 5 18:08:01 UTC 2020

#51255: REST API: Support request level validation
 Reporter:  TimothyBlynJacobs  |       Owner:  TimothyBlynJacobs
     Type:  enhancement        |      Status:  closed
 Priority:  normal             |   Milestone:  5.6
Component:  REST API           |     Version:  4.4
 Severity:  normal             |  Resolution:  fixed
 Keywords:                     |     Focuses:
Changes (by TimothyBlynJacobs):

 * owner:  (none) => TimothyBlynJacobs
 * status:  new => closed
 * resolution:   => fixed


 In [changeset:"48945" 48945]:
 #!CommitTicketReference repository="" revision="48945"
 REST API: Support a route-level validation callback.

 Most request data is validated on a per-parameter basis. Often, however,
 additional validation is needed that operates on the entire request
 object. Currently, this is done in the route callback and often in the
 `prepare_item_for_database` method specifically.

 #50244 aims to introduce batch processing in the REST API. An important
 feature is the ability to enforce that all requests have valid data before
 executing the route callbacks in "pre-validate" mode.

 This patch introduces support for calling a `validate_callback` after all
 parameter validation has succeeded. That allows moving more validation
 outside of the route callback and into `WP_REST_Request` which will
 improve "pre-validate" support.

 Props TimothyBlynJacobs, zieladam.
 Fixes #51255.
 See #50244.

Ticket URL: <https://core.trac.wordpress.org/ticket/51255#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list