I've explored further since then and fixed the doubling issue, but I'm still a bit lost as to how to nicely configure the error messages.
How are rules supposed to be named? It seems that the rule name is prepended to any error statements, so from the docs: the rule
barcode_only would result in an error message like "Barcode only must be filled" which makes no sense.
Likewise, I'm having to rename my rule messages to get meaningful output. Here's my rule:
ArticleForm = Dry::Validation.Form do
required(:short_title).maybe(:str?, max_size?: 30)
rule(short_title_present: [:default_title, :short_title]) do |default_title, short_title|
short_title_present: 'is required when the default title is longer than 30 characters'
This gives the error "Short title present is required when the default title is longer than 30 characters" (emphasis mine). I then have to add extra config to rename my rule:
short_title_present: 'short title'