[wp-trac] [WordPress Trac] #49960: REST API: Support sanitize callbacks for nested properties

WordPress Trac noreply at wordpress.org
Mon Apr 20 15:53:43 UTC 2020


#49960: REST API: Support sanitize callbacks for nested properties
-------------------------+------------------------------------------
 Reporter:  ocean90      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  REST API     |    Version:
 Severity:  normal       |   Keywords:  needs-patch needs-unit-tests
  Focuses:               |
-------------------------+------------------------------------------
 Example schema:

 {{{
 'foobar' => [
         'required'    => true,
         'type'        => 'object',
         'properties'  => [
                 'foo' => [
                         'required'          => true,
                         'type'              => 'string',
                         'sanitize_callback' => 'sanitize_text_field',
                 ],
                 'bar'    => [
                         'required'          => true,
                         'type'              => 'string',
                         'sanitize_callback' => [ static::class,
 'sanitize_bar' ],
                 ],
         ],
 ],
 }}}


 Unfortunately, the `required` and `sanitize_callback` values are currently
 not used for properties. `required` is now handled in #48818. With support
 for `sanitize_callback` we'd have another way to enforce a specific format
 without much hassle.

 Related:
 * https://github.com/WP-API/WP-API/issues/2783
 * https://wordpress.slack.com/archives/C02RQC26G/p1576689184011500

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49960>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list