-
-
Couldn't load subscription status.
- Fork 115
Open
Labels
Description
Describe the bug
There can be a case when no schema for a hash is set. In such a case, there's not need to validate keys. I might be wrong but it's just logical to me.
To Reproduce
DemoSchema = Dry::Schema.define do
config.validate_keys = true
required(:addresses).array(:hash)
end
DemoSchema.call({addresses: [{number: "oo"}]})
=> #<Dry::Schema::Result{:addresses=>[{:number=>"oo"}]} errors={:addresses=>{0=>{:number=>["is not allowed"]}}} path=[]>Expected behavior
The validation passes. We didn't specify any key for nested hashes, key validation shouldn't be applied in such cases. I would expect such values to be validated at later stages with rules or custom code.
My environment
- Affects my production application: NO
- Ruby version: 3.2.0
- OS: N/A
stoivo, nelson-vantage, jmtame, JanecekJ, crutch and 6 more