You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 to 0.
After a lot of searching in
The upsell schema
The salesarea schema
The relationships in the route
The upsell and salesarea policies
The data I'm sending on the frontend
I figured out that the issue lied with the Request, I had named rule salesareas (referring to the resource name: "salesareas") and not salesarea (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.
The text was updated successfully, but these errors were encountered:
Azeirah
changed the title
Rules in a a ResourceRequest are not checked against the defined fields
Rules in a a ResourceRequest are not checked against the Schema's defined fields -- no exception thrown for an incorrect Request
May 7, 2024
Azeirah
changed the title
Rules in a a ResourceRequest are not checked against the Schema's defined fields -- no exception thrown for an incorrect Request
Rules in a a ResourceRequest are not checked against the Schema's defined fields; no exception thrown for an incorrect Request
May 7, 2024
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)
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.
The text was updated successfully, but these errors were encountered: