Hello, I have a schema which requires a metrics
key whose value is an array of tuples, where the tuples must be [:string, :integer]
. The strings must be filled and the integers must be positive. Here’s a simple example of valid data:
{
"metrics": [
["start", 153535255],
["sendRequest", 153535258],
["receiveResponse", 153535260]
]
}
I’ve got the SchemaContract validating with this subset:
class SchemaContract < Dry::Validation::Contract
schema do
required(:metrics).array do
array? && size?(2)
end
...
Any suggestions for how I can validate the tuple rules themselves? (I don’t see a tuple
type, but could I define one so it could be as succinct as tuple[filled(:string), value(:integer, gt?: 0)]
?)
Thank you!