WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#52375 closed enhancement (fixed)

Extract the validation of specific data types from rest_validate_value_from_schema() into separate functions

Reported by: yakimun Owned by: TimothyBlynJacobs
Milestone: 5.7 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch
Focuses: Cc:

Description

The current implementation of the rest_validate_value_from_schema function contains a lot of code and is difficult to read. Most of the code of this function is related to the validation of specific data types.

We can extract the type validation logic into separate functions to improve readability and maintainability.

Change History (4)

This ticket was mentioned in PR #924 on WordPress/wordpress-develop by yakimun.


9 months ago

  • Keywords has-patch added

Specific types validation logic extracted from the rest_validate_value_from_schema function into separate functions.

Trac ticket: https://core.trac.wordpress.org/ticket/52375

#2 @TimothyBlynJacobs
9 months ago

  • Milestone changed from Awaiting Review to 5.7
  • Version set to 4.7

Thanks for the patch, this is a great improvement @yakimun!

#3 @TimothyBlynJacobs
9 months ago

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

In 50060:

REST API: Refactor rest_validate_value_from_schema into separate validation functions per-type.

Props yakimun.
Fixes #52375.

Note: See TracTickets for help on using tickets.