These are chat archives for dry-rb/chat
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?