dry-validation> class ValidateContract < Dry::Validation::Contract
params do
required(:outerHash).hash do
required(:innerArray).array(:string)
end
dry-validation> class ValidateContract < Dry::Validation::Contract
params do
required(:outerHash).hash do
required(:innerArray).array(:string)
end
end
end
=> #<Dry::Schema::Params keys=[{"outerHash"=>["innerArray"]}] rules={:outerHash=>"key?(:outerHash) AND key[outerHash](hash? AND set(key?(:innerArray) AND key[innerArray](array? AND each(str?))))"}>
dry-validation> c = ValidateContract.new
=> #<#<Class:0x000000010581dd40>::ValidateContract schema=#<Dry::Schema::Params keys=[{"outerHash"=>["innerArray"]}] rules={:outerHash=>"key?(:outerHash) AND key[outerHash](hash? AND set(key?(:innerArray) AND key[innerArray](array? AND each(str?))))"}> rules=[]>
dry-validation> h = {
"outerHash": { "innerArray": [ "test1", "test2" ] }
}
=> {:outerHash=>{:innerArray=>["test1", "test2"]}}
dry-validation> c.(h)
=> #<Dry::Validation::Result{:outerHash=>{:innerArray=>["test1", "test2"]}} errors={}>