Hash? validation doesn't work with string keys?

#1

Hi! I’m trying to integrate dry-validation into a project of mine, and I’m noticing that it doesn’t work if you use a string as the key (i.e. { 'example_key' => example_value}. Is this intended? Or is there a way to work with hashes that use this format?

0 Likes

#2

Which schema type did you use? Please provide some code examples.

0 Likes

#3

An example of how the schema was set up would be like this:
Dry::Validation.Schema do
required(:example_hash) { filled? > hash }
end

Which would be filled in by a hash that is formatted like this: example_hash: { 'a' => 1 }

0 Likes

#4

For string keys you want Dry::Validation.Params do ... end.

0 Likes