WordPress.org

Make WordPress Core

#50509 closed enhancement (maybelater)

Json schema validation

Reported by: sorenbronsted Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: dev-feedback 2nd-opinion
Focuses: rest-api Cc:

Description

Instead of implementing json schema validation there exists implementations for php out there in the wild. I will suggest using one of these instead of inventing the wheel once again :-)

Change History (2)

#1 @TimothyBlynJacobs
15 months ago

  • Version set to 4.7

Thanks for the ticket @sorenbronsted!

Did you have any libraries in mind?

Some things we need to consider:

  1. Sanitization. Our schema implementation also supports sanitizing values. Are there any other json schema libraries that do this?
  2. Translation. The libraries I've seen aren't very amenable to translating the error messages. They also often concatenate parts of different English strings together, which doesn't work for all languages.
  3. Type conversion. We need to make sure things like are boolean checks behave the same way. Additionally we support csv syntax for arrays. This would need to be checked for all types.
  4. v3 required syntax.
  5. Our schema validators don't work on an entire schema for top level requests properties. So we'd need to transform those values into something the validator could work with.
  6. Dependency size. Our schema validator is comparably small to the other PHP schema validators I've seen. We don't want to bring on a large dependency.

#2 @TimothyBlynJacobs
11 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing per my latest comment. If something significantly changed around WP's attitude to including third party libraries, and we wanted to totally redo our schema validation, we could maybe take a look at this then. But I don't foresee this happening in the short-medium term.

Note: See TracTickets for help on using tickets.