Restler icon indicating copy to clipboard operation
Restler copied to clipboard

Validation check causes parameter with value 0 to be set to NULL

Open yeehahboogie opened this issue 8 years ago • 1 comments

https://github.com/Luracast/Restler/blob/06f0cadc14a5e47d52c431abb6f60197e7c0b2e2/vendor/Luracast/Restler/Data/Validator.php#L500

I've patched a check for 0 onto the end in my code, you may prefer something else:

                if (!$info->required && empty($input) && $input !== 0) {
                    //optional parameter with a empty value assume null
                    return null;
                }

The use case that triggered this was a property with a custom validator that has a default of 0 (its a default pagination offset)

yeehahboogie avatar Oct 10 '18 02:10 yeehahboogie

This is fixed in Restler 5 currently in the v5 branch which will soon be pushed to master

Arul- avatar Jul 19 '21 06:07 Arul-