Does dry-validation support schemas where the top level is an Array?

I’ve been trying to integrate dry-validation into a legacy app to have better validation of incoming data.

Some of the data is has this JSON layout:

[
  {
    "affects_url": "http://localhost/" ,
    "confidence": 95
  },
  {
    "affects_url": "http://localhost/favicon.ico" ,
    "confidence": 95
  }
]

And my attempts of writing a contract for this so far have failed.

I thought, that this should work, but it returns an empty result:

class MyContract < Dry::Validation::Contract
  json do
    array do
      required(:affects_url).filled(:string)
      required(:confidence).filled(:integer)
    end
  end
end

It’s a feature request in dry-schema Provide a way of defining schemas for arrays as root nodes · Issue #22 · dry-rb/dry-schema · GitHub I wrap such data with a key Schema.(data: json)

Oh, that’s a great workaround, thanks for the tip!