These are chat archives for dry-rb/chat
I have a situation where a field (answer) is dynamic… it can be a number, a date or one of a set of options…
rule(answer: [:answer, :kind, :optional, :options]) do |answer, kind, optional, options| (optional.false? > answer.filled?) & ((answer.filled? & kind.eql?('number')) > answer.number?) & ((answer.filled? & kind.eql?('date')) > answer.iso8601?) & ((answer.filled? & kind.eql?('options')) > answer.included_in?(options)) end
Seems to work ok, but the issue is that if blank, error messages pick up “must be a number, must be a date, must be one of …”.
is there a better way?
i guess i’m trying to understand how the message is being generated.
I’m about to dive into source, but haven’t yet.
when we have (a & b) > c
and a is false, i’d expect the then to not fire
however, it appears we have validation messages on that