Skip to content

Empty hashes not detected by validate_keys is true #349

Open
@patodevilla

Description

@patodevilla

Describe the bug

When setting validate_keys as true, empty hashes are being ignored by the validator

To Reproduce

schema = Dry::Schema.JSON do
  config.validate_keys = true
end
schema.({hello: {}})
 => #<Dry::Schema::Result{} errors={}> 
schema.({hello: 1})
 => #<Dry::Schema::Result{} errors={:hello=>["is not allowed"]}>

Expected behavior

Unexpected key hello should be in the errors hash regardless of the key's value

My environment

  • Affects my production application: YES
  • Ruby version: ruby-2.5.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions