These are chat archives for dry-rb/chat

7th
Aug 2017
Phillip Oertel
@phillipoertel
Aug 07 2017 11:28
Hi everyone, I have an issue with dry-validations; it may be a bug related to reusing schemas; can anyone help?
Phillip Oertel
@phillipoertel
Aug 07 2017 11:34
Well, I'll leave my question here, maybe someone sees it later ...

When reusing a schema like this:

optional(:voucher_code, [:nil, :hash]).maybe do
  schema(VoucherValidations::Schema)
end

and defining a high-level rule in VoucherValidations::Schema like this:

optional(:current_crew_id).maybe(:int?)
optional(:crew_id).maybe(:int?)
rule(crew_id_must_match: [:crew_id, :current_crew_id]) do |crew_id, current_crew_id|
  crew_id.filled?.then(crew_id.eql?(current_crew_id))
end

When there's an error validating the outer schema, the error message from the inner schema is not stored in
errors[:voucher_code][:crew_id_must_match] but on the top-level. I'd expect the error in on the inner schema, just
like the other, "low-level" validations (like current_crew_id being an int). This also happens when I replace the rule with a validate block.
I couldn't find a GH issue for that, is that a bug or a feature? Is there a way to get the error to be nested?

Phillip Oertel
@phillipoertel
Aug 07 2017 12:32
Oh, btw config.messages is set to :i18n.
Sergey Prikhodko
@prikha
Aug 07 2017 13:21
@GustavoCaso ping me if help needed dry-rb/dry-transaction#67
Rafael George
@cored
Aug 07 2017 20:11
hi is there any documentation about testing transactions defined with dry-transactions/
?