Skip to content
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

Ensure specification validation checks relations are of expected type (to-one or to-many) #15

Closed
lindyhopchris opened this issue Feb 5, 2021 · 2 comments

Comments

@lindyhopchris
Copy link
Contributor

RE: this issue:
cloudcreativity/laravel-json-api#335

We need to ensure that the specification validator rejects a document that has the wrong type of relation - e.g. submitting a to-many for a to-one, and vice versa.

The spec validator now has access to this information via the schema classes.

I suspect I've already implemented this, but just need to double-check that it is implemented and tested before closing this issue!

@lindyhopchris
Copy link
Contributor Author

lindyhopchris commented Feb 6, 2021

The spec library is rejecting a to-one for a to-many relation, and vice versa, but the message isn't great. For to-one it says the data member should be an object; for a to-many it says the member should be an array.

Would be an improvement if it rejected saying: The field author must be a to-one relation. and The field tags must be a to-many relation.

@lindyhopchris
Copy link
Contributor Author

Will be released in the spec package 1.0.0-alpha.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant