| 35 | | I'd suggest: if `$args['properties']` is empty inside `rest_sanitize_value_from_schema`, that no validation should occur (for backward compatibility, that was the previous behaviour), instead of only considering an empty object valid (current behaviour). |
| 36 | | |
| 37 | | ie, inside `rest_sanitize_value_from_schema`, replace the code that deals with args of type object with this |
| 38 | | {{{#!php |
| 39 | | if ( 'object' === $args['type'] ) { |
| 40 | | if ($value instanceof stdClass) { |
| 41 | | $value = (array)$value; |
| 42 | | } |
| 43 | | if (! is_array($value)) { |
| 44 | | return array(); |
| 45 | | } |
| 46 | | if (isset($args['properties'])) {// <--- new |
| 47 | | foreach ($value as $property => $v) { |
| 48 | | if (! isset($args['properties'][$property])) { |
| 49 | | unset($value[$property]); |
| 50 | | continue; |
| 51 | | } |
| 52 | | $value[$property] = rest_sanitize_value_from_schema($v, $args['properties'][$property]); |
| 53 | | } |
| 54 | | }// <---- new |
| 55 | | }}} |
| | 35 | --- I removed my code suggestion. I now think @TimothyBlynJacobs 's original approach, to have an `additionalProperties` argument, is best. |