There is no such maxLength
option in the WP REST API.
You can pass a validate_callback
though. Example:
<?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 );
}
),
),
) );
} );
Source: https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/