Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50053 closed enhancement (fixed)

REST API: Support uuid json schema format

Reported by: timothyblynjacobs's profile TimothyBlynJacobs Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: json-schema good-first-bug has-patch has-unit-tests
Focuses: rest-api Cc:


We should add support for format: "uuid" in rest_validate_value_from_schema. We can use the existing wp_is_uuid function for validation. And I'd imagine sanitize_text_field for sanitization.

At the moment, I think we can skip checking for a specific uuid version.

The list of formats is extensible, but uuid is also included as a format in the latest specs.

Change History (6)

This ticket was mentioned in PR #247 on WordPress/wordpress-develop by johnwatkins0.

4 years ago

This adds support for the uuid format in WP REST JSON schema. As suggested in the ticket description, the format is validated with wp_is_uuid and sanitized with sanitize_text_field.

#2 @johnwatkins0
4 years ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

#3 @TimothyBlynJacobs
4 years ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from new to closed

In 47753:

REST API: Support the uuid JSON Schema format.

This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version.

Props johnwatkins0.
Fixes #50053.

johnwatkins0 commented on PR #247:

4 years ago

Thanks, @TimothyBJacobs !

#6 @TimothyBlynJacobs
4 years ago

In 47811:

REST API: Add @since entries for rest_validate_value_from_schema().

See #49572, #48818, #44949, #50053, #48820, #49720, #42961, #44975, #43392, #38583.

Note: See TracTickets for help on using tickets.