# Inconsistency in resolving full error messages

**URL:** <https://discourse.dry-rb.org/t/inconsistency-in-resolving-full-error-messages/1091>\
**Category:** dry-validation\
**Created:** [July 20, 2020, 6:18pm UTC](https://discourse.dry-rb.org/t/inconsistency-in-resolving-full-error-messages/1091 "2020-07-20T18:18:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stind](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/stind/32/542_2.png) [@stind](https://discourse.dry-rb.org/u/stind)\
**Post date:** [July 20, 2020, 6:18pm UTC](https://discourse.dry-rb.org/t/inconsistency-in-resolving-full-error-messages/1091/1 "2020-07-20T18:18:34Z")

</div>

Full error messages work fine when I pass a string message, e.g. `key.failure("is invalid")`. The full message includes the translated key (e.g. `"Full Name is invalid"`), or the key itself if there’s no translation (e.g. `"full_name is invalid"`)

However, if I pass a symbol, e.g. `key.failure(:invalid)`, and the rule has no translation, the full error message will not include the key (e.g. `" is invalid"`)

```ruby
require "i18n"
require "dry/validation"

I18n.backend.store_translations(
  :en,
  {
    dry_validation: {
      rules: {
        foo: "Translated Foo"
      },
      errors: {
        is_invalid: "is invalid"
      }
    }
  }
)

class WithStringMessages < Dry::Validation::Contract
  config.messages.backend = :i18n

  params do
    required(:foo).value(:integer)
    required(:bar).value(:integer)
  end

  rule(:foo) do
    key.failure("is invalid") if value < 0
  end

  rule(:bar) do
    key.failure("is invalid") if value < 0
  end
end

class WithSymbolMessages < Dry::Validation::Contract
  config.messages.backend = :i18n

  params do
    required(:foo).value(:integer)
    required(:bar).value(:integer)
  end

  rule(:foo) do
    key.failure(:is_invalid) if value < 0
  end

  rule(:bar) do
    key.failure(:is_invalid) if value < 0
  end
end

puts WithStringMessages.new.call(foo: -1, bar: -1).errors(full: true).map(&:text).inspect
#=> ["Translated Foo is invalid", "bar is invalid"]

puts WithSymbolMessages.new.call(foo: -1, bar: -1).errors(full: true).map(&:text).inspect
#=>["Translated Foo is invalid", " is invalid"]

```

It is especially relevant when I want to use a dry-logic predicate as a macro.

```ruby
rule(:foo).validate(gt?: 0)
# full error message for that: " must be greater than 0"

```

I think there’s no issue with adding a fallback to the key name if it couldn’t find the translation.  
I’m keen to open an Issue/PR for that, but wanted to discuss it here first.  
Thanks.

_ruby 2.6.6_  
_dry-validation 1.5.2_

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/solnic/32/779_2.png) [@solnic](https://discourse.dry-rb.org/u/solnic)\
**Post date:** [July 22, 2020, 9:30am UTC](https://discourse.dry-rb.org/t/inconsistency-in-resolving-full-error-messages/1091/2 "2020-07-22T09:30:39Z")

</div>

hey there, this is clearly a bug so please report an issue. A PR would be even better 😄
