Search code examples
phpjsonapipatchrestler

Luracast Restler Validator returns warning about expecting string, getting array


I'm sending the following json: {"name":"New event"}

to a PATCH handler: function patch($id, $request_data = NULL)

but am getting the following warning: Warning: strlen() expects parameter 1 to be string, array given in /public_html/vendor/Luracast/Restler/Data/Validator.php on line 115

The source at that line is:

switch ($info->type) {
    ...
    case 'string' :
       $r = strlen($input);

So I added some code to the first line of Validator.validate() see what it thinks the variables are:

print("$input: $info->type\n");

and I get this:

1: int
Array: string

So it thinks the array is a string. It is still able to continue and process the request, but it returns this warning as the response instead of something valid I can process.

Any ideas what I'm doing wrong?


Solution

  • Latest version (Restler 3 RC4) in v3 branch fixes this issue