Hi all,
I’ve been diving into dry-validation recently and really enjoying what I’ve seen so far. But, I’ve hit a snag and can’t find the answer anywhere online or in the forums.
I’ve created a high-level rule and I’m having trouble getting a sane error message for it.
rule(short_title_present: [:default_title, :short_title]) do |default_title, short_title|
default_title.max_size?(30).or(short_title.filled?)
end
I’d like to specify a single custom message for this rule, like “A short title is required when the default title is longer than 30 characters”. But I end up with this instead: “Short title present a short title is required when the default title is longer than 30 characters or short title present a short title is required when the default title is longer than 30 characters”. Woah! My message is being added for each part of the compound rule… how can I avoid this?
Here’s my config:
configure do
def self.messages
super.merge(
en: {
errors: {
short_title_present: 'A short title is required when the default title is longer than 30 characters',
}
}
)
end
end
Thanks for any advice,
~Alex