[wp-trac] [WordPress Trac] #44949: Add support for JSON Schema string pattern to REST API

WordPress Trac noreply at wordpress.org
Sat Sep 15 00:23:17 UTC 2018


#44949: Add support for JSON Schema string pattern to REST API
-----------------------------+-----------------------------
 Reporter:  jason_the_adams  |      Owner:  (none)
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  REST API         |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 According to the JSON Schema regular expression patterns are a part of the
 spec: https://json-schema.org/understanding-json-
 schema/reference/string.html#regular-expressions

 The `rest_validate_value_from_schema` validates some of the schema, but
 omits this. It's certainly possible to provide a `validate_callback` to
 the endpoint, but since this is a valid part of the schema it would be
 great to be able to validate based on the pattern.

 I believe this is simple yet useful enough to quickly become a helpful
 addition to the REST API. Furthermore, I believe it's safe to add. If
 someone does use the pattern they're probably using `validate_callback` to
 check the regex already, or I doubt they would mind the REST API flagging
 it as... well... that's the point of the spec. :)

 Interested in thoughts and feedback!

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


More information about the wp-trac mailing list