-
Notifications
You must be signed in to change notification settings - Fork 106
Rule Validator needs recursively convert attributes to an array. #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@lindyhopchris hello I'm using cloudcreativity/laravel-json-api v0.2.1 and I believe I found another bug with the object to array conversion. For structures that contain an array of objects, these won't get converted into arrays: // request attributes
"multiple": [
{
"val1": "one",
"val2": "two"
},
{
"val3": "three",
"val4": "four"
}
],
"nestedObj": {
"obj1": {
"val1": "one",
"val2": "two"
},
"obj2": {
"val3": "three",
"val4": "four"
}
}
// toArray conversion of attributes
"multiple" => [
{
"val1": "one",
"val2": "two"
},
{
"val3": "three",
"val4": "four"
}
],
"nestedObj" => [
"obj1" => [
"val1" => "one",
"val2" => "two"
],
"obj2" => [
"val3" => "three",
"val4" => "four"
]
} This same behavour happens regardless of the nesting level. Please let me know if I can help any further. |
Hi @nickelozz Sorry for slow reply - been on holiday. Yes, this is definitely a bug. I'll be able to look at it on Monday when I'm back from holiday. Cheers, |
Believe I've now fixed this if you update your |
@lindyhopchris I've tested and it works now...thanks so much. Apparently in the upcoming version (5.2) of Laravel a lot of what I've been doing manually will be "laravelized" thanks to the new "Form Array Validation"... oh well it was a learning experience 😃 In case anyone wants to read about it check here: https://laravel-news.com/2015/11/laravel-5-2-a-look-at-whats-coming/ |
As reported here:
cloudcreativity/json-api#18
This line:
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Validator/Attributes/RulesValidator.php#L149
Needs to recursively change the object to an array before passing into the Laravel validator.
The text was updated successfully, but these errors were encountered: