[wp-trac] [WordPress Trac] #64311: Abilities API: add filters for input and ouput validation

WordPress Trac noreply at wordpress.org
Wed Nov 26 15:42:27 UTC 2025


#64311: Abilities API: add filters for input and ouput validation
-------------------------+-----------------------
 Reporter:  priethor     |      Owner:  priethor
     Type:  enhancement  |     Status:  assigned
 Priority:  normal       |  Milestone:  7.0
Component:  AI           |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------
 The Abilities API currently validates ability input and output against
 JSON Schema using WordPress's built-in
 `rest_validate_value_from_schema()`, which supports only a subset of JSON
 Schema Draft 4 (aligning with WordPress core). This approach is reliable
 for core compatibility but limits extenders to dated JSON Schema features,
 missing newer ones like `$ref` references for composability and
 reusability, and `not` keyword to exclude patterns.

 Developers extending the Abilities API that need more expressive schema
 validation have no way to override the default validator without forking
 or monkey-patching.

 == Proposed Solution ==

 Introduce two hooks to allow custom validation:

 {{{#!php
 /**
  * Filters the input validation result for an ability.
  *
  * @since 7.0.0
  *
  * @param true|WP_Error $is_valid Validation result (true or WP_Error).
  * @param mixed         $input    The input being validated.
  * @param string        $name     The ability name.
  */
 apply_filters( 'wp_ability_validate_input', $is_valid, $input, $name );

 /**
  * Filters the output validation result for an ability.
  *
  * @since 7.0.0
  *
  * @param true|WP_Error $is_valid Validation result (true or WP_Error).
  * @param mixed         $output   The output being validated.
  * @param string        $name     The ability name.
  */
 apply_filters( 'wp_ability_validate_output', $is_valid, $output, $name );
 }}}

 == Related ==

 * GitHub Issue: https://github.com/WordPress/abilities-api/issues/149
 * GitHub PR: https://github.com/WordPress/abilities-api/pull/150

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


More information about the wp-trac mailing list