# Unexpected behaviour with validate\_keys

**URL:** <https://discourse.dry-rb.org/t/unexpected-behaviour-with-validate-keys/1203>\
**Category:** Uncategorized\
**Created:** [February 18, 2021, 7:10pm UTC](https://discourse.dry-rb.org/t/unexpected-behaviour-with-validate-keys/1203 "2021-02-18T19:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![woto](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/woto/32/529_2.png) [@woto](https://discourse.dry-rb.org/u/woto)\
**Post date:** [February 18, 2021, 7:10pm UTC](https://discourse.dry-rb.org/t/unexpected-behaviour-with-validate-keys/1203/1 "2021-02-18T19:10:18Z")

</div>

Hi. Is it documented behaviour? I think it is not.

```auto
require 'dry-validation'
require 'dry/validation/version'

class NewUserContract < Dry::Validation::Contract
  params do
    config.validate_keys = true
    required(:email).filled(:string)
    required(:age).value(:integer)
  end
end

contract = NewUserContract.new

p contract.call(email: 'jane@doe.org', age: '17', mail: rand(), unexpected_too: rand())
p Dry::Validation::VERSION

```

```auto
#<Dry::Validation::Result{:email=>"jane@doe.org", :age=>17} errors={:unexpected_too=>["is not allowed"]}>
"1.6.0"

```

It blames : unexpected\_too key, but not :mail  
Seems it’s happened because `mail` is a substring of `email`

Sorry didn’t have time to go deeper.

---

<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:** [February 19, 2021, 5:50am UTC](https://discourse.dry-rb.org/t/unexpected-behaviour-with-validate-keys/1203/2 "2021-02-19T05:50:34Z")

</div>

hey please report an issue on GitHub under dry-rb/dry-schema repo

---

<div class="post-metadata">

**Author:** ![woto](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/woto/32/529_2.png) [@woto](https://discourse.dry-rb.org/u/woto)\
**Post date:** [February 19, 2021, 10:09pm UTC](https://discourse.dry-rb.org/t/unexpected-behaviour-with-validate-keys/1203/3 "2021-02-19T22:09:58Z")

</div>

done [Unexpected behaviour with validate\_keys · Issue #344 · dry-rb/dry-schema · GitHub](https://github.com/dry-rb/dry-schema/issues/344)
