-
-
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
Result "errors(full: true).to_h" method output not expected #618
Comments
Ok, maybe I've not checked the API documentation properly. I should be calling failure with a meta hash parameter if I want to keep the key: Is that right? Still, it is kind confusing because I am calling failure on the key already |
You're right. This is a bug. Thanks for reporting. |
Shouldn't it be moved to dry-validation? |
I started to fix this bug and found strange behaviour: When validation fails in params and rule definitions, then only error from params will be shown, error message from rule will be skipped. For example: contract.call(pin: "a").errors(full: true).to_h # two errors, less than 4 and not digit
# {:pin=>["pin length must be 4"]} But when params check passed we can see rule error contract.call(pin: "abcd").errors(full: true).to_h
# {:pin=>["must be only integer"]} Is it expected behaviour? I suppose, all error messages should be shown after validation: contract.call(pin: "a").errors(full: true).to_h
# {:pin=>["pin length must be 4", "pin must be only integer"]} |
@korrs absolutely, you cannot run rule checks on ill-typed input |
👌 |
Hello love dryrb and love to help with this one, Will create pr with proposed solution |
This was fixed in 1.5.1 |
The expected value for
Dry::Validation::Result
instance methoderrors
is toThe current behavior is that, for
params do
the key is added to the message, but forrule do
that adds a failure to the key it isn't:dry-validation: 1.4
The text was updated successfully, but these errors were encountered: