Unexpected behaviour with validate_keys

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

require 'dry-validation'
require 'dry/validation/version'

class NewUserContract < Dry::Validation::Contract
  params do
    config.validate_keys = true

contract = NewUserContract.new

p contract.call(email: 'jane@doe.org', age: '17', mail: rand(), unexpected_too: rand())
p Dry::Validation::VERSION
#<Dry::Validation::Result{:email=>"jane@doe.org", :age=>17} errors={:unexpected_too=>["is not allowed"]}>

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.

1 Like

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

done Unexpected behaviour with validate_keys · Issue #344 · dry-rb/dry-schema · GitHub

1 Like