没有这样的maxLength
WP REST API中的选项。
你可以通过validate_callback
虽然示例:
<?php
add_action( \'rest_api_init\', function () {
register_rest_route( \'myplugin/v1\', \'/author/(?P<id>\\d+)\', array(
\'methods\' => \'GET\',
\'callback\' => \'my_awesome_func\',
\'args\' => array(
\'id\' => array(
\'validate_callback\' => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
) );
} );
资料来源:
https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/