# Difficulty creating error messages for high-level rules

**URL:** <https://discourse.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238>\
**Category:** dry-validation\
**Created:** [March 16, 2017, 5:50pm UTC](https://discourse.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238 "2017-03-16T17:50:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![heeton](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/heeton/32/93_2.png) [@heeton](https://discourse.dry-rb.org/u/heeton)\
**Post date:** [March 17, 2017, 10:46am UTC](https://discourse.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238/2 "2017-03-17T10:46:16Z")

</div>

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:

```auto
require 'dry-validation'

ArticleForm = Dry::Validation.Form do
  required(:default_title).filled(:str?)
  required(:short_title).maybe(:str?, max_size?: 30)

  rule(short_title_present: [:default_title, :short_title]) do |default_title, short_title|
    (default_title.size?(0..30).not).then(short_title.filled?)
  end

  configure do
    def self.messages
      super.merge(
        en: {
          errors: {
            short_title_present: 'is required when the default title is longer than 30 characters'
          }
        }
      )
    end
  end

end

```

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:

```auto
          rules: {
            short_title_present: 'short title'
          }

```

---

_[View the full topic](https://discourse.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238)._
