Closed Azeirah closed 4 months ago
Yeah agree this is tricky with the current version. You have to add validation rules, as we only use validated data. It's a bit of a gotcha that's caught people out.
I'm actually going to close this issue, as this is solved in the next major version. We're moving validation to the fields on the schema, which makes it clearer as to what's going on. You can see an example of that here: https://github.com/laravel-json-api/laravel/issues/39#issuecomment-2101260482
Yeah agree this is tricky with the current version. You have to add validation rules, as we only use validated data. It's a bit of a gotcha that's caught people out.
I'm actually going to close this issue, as this is solved in the next major version. We're moving validation to the fields on the schema, which makes it clearer as to what's going on. You can see an example of that here: #39 (comment)
Ah, awesome! I'll keep a close eye on development, and will be providing feedback when I have some.
I'm still new to Laravel JSON API. I had a
The accompanying schema is as follows
I tried creating a new Upsell with a salesarea relation, and sent the following data
The resource is created succesfully (200 OK), the Upsell model with name
Test
is created, all looks ok!After inspecting the created model, I found that the
salesarea_id
is set to0
.After a lot of searching in
I figured out that the issue lied with the Request, I had named rule
salesareas
(referring to the resource name:"salesareas"
) and notsalesarea
(referring to the field in the schema).I'm noticing that in general it's very difficult to know which naming convention to use when, and I really hope it could be included in the base library to throw errors as early as possible to prevent having to search through all the related logic for a tiny singular typo or confusion between a schema field and relation.