-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix validation error for nested array when requires
=> optional
=> requires
#2128
Conversation
1714f21
to
33a57a9
Compare
…> `requires` This bug is due to the params parsing code return `{}` when the value is not found. This is fine in most cases, however in the instance that the value was optional and has nested required values. I was not able to find a way to confind the changes to just the parameter parsing as this resulted in the indexing being incorrect if any of the other array objects had an error. I have used a class to indicate that an Optional Value was missing as this avoid issues with the value actually being in the response.
Looks like there are some legit spec failures here ... cc: @stanhu @dm1try @dnesteryuk who dealt with params recently to add some comments |
# are the parameter parsing stage as they are required to ensure | ||
# the correct indexing is maintained | ||
def skip?(val) | ||
# return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
Try writing more specs with other combinations of required parameters inside optional ones? I suspect we have similar problems with hash parameters and combinations of arrays and hashes. |
…onents This adds a number of tests around edge cases and different structures that could result in the previous validation incorrectly reporting missing data as a result of an optional element not being present.
741ed9b
to
2647e2c
Compare
@dblock added tests for all the edge cases that I believe this would affect and they all pass with this change. Let me know if you can think of anything else it would be worth testing. |
i'm merging this |
This bug is due to the params parsing code return
{}
when the value is not found.This is fine in most cases, however in the instance that the value was optional
and has nested required values.
I was not able to find a way to confine the changes to just the parameter parsing
as this resulted in the indexing being incorrect if any of the other array objects
had an error.
I have used a class to indicate that an Optional Value was missing as this avoid issues
with the value actually being in the response.