We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi ✌️ Not sure if I use rules correctly, but looks like its a bug. Please take a look. Thank you.
Describe the bug
Rule for nested attributes is being executed despite schema contains invalid values.
To Reproduce
require 'dry/validation' class ExampleContract < Dry::Validation::Contract params do required(:contract).schema do required(:active_from).value(:date) required(:active_until).value(:date) end end rule(contract: [:active_from, :active_until]) do key.failure('ops') if value[0] < value[1] end end f = (Date.today - 1000).to_s u = (Date.today + 1000).to_s puts ExampleContract.new.call(contract: { active_from: f, active_until: u }).inspect #<Dry::Validation::Result{:contract=>{:active_from=>#<Date: 2016-11-02 ((2457695j,0s,0n),+0s,2299161j)>, :active_until=>#<Date: 2022-04-25 ((2459695j,0s,0n),+0s,2299161j)>}} errors={:contract=>{[:active_from, :active_until]=>["ops"]}}> puts ExampleContract.new.call(contract: { active_from: 'abc', active_until: u }).inspect # comparison of String with Date failed (ArgumentError)
Expected behavior
Rule should not be executed when schema is invalid.
The text was updated successfully, but these errors were encountered:
Thanks for the report. I'll fix it in the next bug fix release.
For now, as a workaround, use dot-notation:
rule("contract.active_from", "contract.active_until") do key.failure('ops') if values["contract.active_from"] < values["contract.active_until"] end
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Hi ✌️ Not sure if I use rules correctly, but looks like its a bug. Please take a look. Thank you.
Describe the bug
Rule for nested attributes is being executed despite schema contains invalid values.
To Reproduce
Expected behavior
Rule should not be executed when schema is invalid.
The text was updated successfully, but these errors were encountered: