-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Wrap rule errors by namespace #140
Labels
Comments
It works if I use a rule with the name of one of the required keys: I think, the other way should work, too. validations do
required(:vendor) { type?(String) & present? }
required(:starts_on) { type?(String) & present? }
required(:ends_on) { type?(String) & present? }
rule(ends_on: [:starts_on, :ends_on]) do |starts_on, ends_on|
ends_on.gt?(starts_on)
end
end |
Hi @DSIW thanks for the issue and sorry for the trouble, I'll look as soon as possible ;) |
@DSIW it seems a bug in dry-validations: inner_schema = Dry::Validation.Schema do
required(:vendor) { type?(String) & filled? }
required(:starts_on) { type?(String) & filled? }
required(:ends_on) { type?(String) & filled? }
rule(time_range: [:starts_on, :ends_on]) do |starts_on, ends_on|
ends_on.gt?(starts_on)
end
end
schema = Dry::Validation.Schema do
required(:contract).schema(inner_schema)
end
schema.call(contract: {vendor: '', starts_on: '2019-01-01', ends_on: '2018-01-01'}).messages
# => {:contract=>{:vendor=>["must be filled"]}, :time_range=>["must be greater than 2019-01-01"]}
inner_schema.call({vendor: '', starts_on: '2019-01-01', ends_on: '2018-01-01'}).messages
# => {:vendor=>["must be filled"], :time_range=>["must be greater than 2019-01-01"]} I've asked in dry-rb gitter's chat to know if they can help us. |
Closing as stale conversation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created a minimal example with the problem: https://gist.github.com/DSIW/d8bf6e71ce9fd7b952e74cf7fec9a123
I assume that the error rule
time_range
should be wrapped by thecontract
namespace like thevendor
validation. What do you think?The text was updated successfully, but these errors were encountered: