Dry-validation hints

I have a situation where a field (answer) is dynamic… it can be a number, a date or one of a set of options…

This gist shows it off:

The hints show all the messages for RHS of the “then” – for example if kind is “number” and answer is blank, it shows “must be a number, must be a date, must be one of…”.

Generally speaking, when we have (a & b) then c as a predicate, and a is false, i’d expect the hints not to include ‘c’. However, it appears we have validation messages on that…

How should this be restructured to generate correct hints, and also, if this is expected behaviour, why? How do hints get generated?

Hints are not generated for high-level rules so these are actual errors.

There’s a mistake in your schema (it’s a known issue) - chaining is not supported so:

# this
required(:optional).filled.bool?

# should be this:
required(:optional).filled(:bool?)

Does it work correctly when you change that?

Hmmm, I don’t think so – if you review the gist you can see I call “messages” and get different results from “errors”.

As for the ‘filled.bool?’ vs 'filled(:bool?) it appears to work correctly either way…