[wp-trac] [WordPress Trac] #38583: Support for objects in schema validation and sanitization

WordPress Trac noreply at wordpress.org
Fri Oct 20 19:05:33 UTC 2017


#38583: Support for objects in schema validation and sanitization
----------------------------------------+-----------------------
 Reporter:  rachelbaker                 |       Owner:  rmccue
     Type:  enhancement                 |      Status:  reopened
 Priority:  high                        |   Milestone:  4.9
Component:  REST API                    |     Version:  4.7
 Severity:  major                       |  Resolution:
 Keywords:  has-unit-tests needs-patch  |     Focuses:
----------------------------------------+-----------------------

Comment (by TimothyBlynJacobs):

 I disagree, object validation has use cases beyond just meta or settings.
 It can be used for top-level schemas in core and especially for people
 developing on top of the REST API.

 If we only want whitelisted properties to be in settings and meta when an
 object type is passed, we should set `additionalProperties` to `false` as
 a default argument and merge it with the provided schema.
 `additionalProperties` is not just a simple boolean, yes add properties,
 no, don't add properties. `additionalProperties` itself can be a schema.
 So if you want a meta value that is a list of arbitrarily keyed integers,
 for example...


 {{{
 {
   "type": "object",
   "additionalProperties": {
     "type": "integer"
   }
 }
 }}}

 Just checking for an object type without any listed arguments to solve
 @mnelson4's case would not completely solve the backwards compatibility
 issues because the previous behavior would be allow any properties
 registered, not just ones specified.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38583#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list