-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
adds support of explict argument for #rule_error? method #673
Conversation
lib/dry/validation/evaluator.rb
Outdated
if path.nil? | ||
!key(self.path).empty? | ||
else | ||
result.error?(path) |
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.
This checks all errors, not just rule errors, so I'm afraid this doesn't do what we want. One option to make this work would be to add Result#rule_error?
that would filter out schema errors and look only at rule errors.
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.
The problem here that schema and rule errors are mixed in Result#errors
set.
So I see two possible solutions:
- Filter schema errors keys from errors set and searching in that subset.
- Check that there are no schema error with provided key and then look up
Result#errors
.
The first approach seems to me is a little more straightforward.
Because in second one you need to know that rule dependent on schema and does not evaluate if there are some error.
But the second one was easier to implement 😄
If second approach is not ok for you I will rewrite it.
0404501
to
63449fd
Compare
@solnic thanks for your review! I have fixed issue. Can you please have a look one more time? Or I need to rewrite it with another approach? |
@moofkit hey sorry for the delay, I was on a sick leave. Thanks for working on this PR. As you can see I just merged it and it'll be included in the 1.6.0 release. |
@solnic thanks! Hope your are well for now! |
Closing #658
Adds support for
#rule_error?
for checking that other rule has errorExample