Skip to content

Conversation

@misdoro
Copy link

@misdoro misdoro commented Dec 3, 2025

Before this change, it was impossible to validate schema for nested arrays of strings or hashes in params, when config.validate_keys = true was set.

Before:

schema = Dry::Schema.Params do
  config.validate_keys = true
  required(:matrix).value(:array, size?: 2).each do
    value(:array, size?: 3).each do
      value(:string, size?: 1)
    end
  end
end

errors = schema.call(matrix: [["a", "b", "c"], ["d", "ee", "f"]]).errors

puts errors.to_h.inspect

would fail validation saying:

{matrix: {0 => {a: ["is not allowed"], b: ["is not allowed"], c: ["is not allowed"]}, 1 => {d: ["is not allowed"], ee: ["is not allowed"], f: ["is not allowed"]}}}

After

a correct validation error for the string length is reported

{:matrix=>{1=>{1=>["length must be 1"]}}}

Before this change, it was impossible to validate schema for nested arrays of strings or hashes in params, when `config.validate_keys = true` was set.
e.g.:
String keys
```
matrix: [["a", "b"], ["c", "d"]]
```

would fail validation saying keys `matrix.0.a` and `matrix.1.c` are not allowed.
@misdoro misdoro changed the title FIX: Add support for nested arrays with config.validate_keys = true FIX support for nested arrays with config.validate_keys = true Dec 4, 2025
@misdoro
Copy link
Author

misdoro commented Dec 10, 2025

Hi @timriley @radar may I ask you for a review please?

@timriley
Copy link
Member

Thanks @misdoro, this looks like a well put together change :) I'll review it as soon as I can. Sometime in the next ~week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants