I’m trying to validate the following shape:
{
tag: :locations,
paths: {
[%w[in near], %w[me us]] => { current_location: true, tag: 'Location' },
[%w[in near], %w[my our], %w[area town community city island state]] => { current_location: true, tag: 'Location' },
[%w[on], %w[my our], %w[island]] => { current_location: true, tag: 'Location' }
},
},
You’ll note that the value for :paths is a Hash will Array keys. How would validating this work?
Thank you!
You can represent this with dry-types, like
Types = Dry.Types(default: :strict)
module Types
Location = Hash.schema(current_location: Bool, tag: String)
Paths = Map(Array.of(Array.of(String)), Location)
end
However, dry-schema does not support the Map
type so this would not work in a schema.
Will dry-schema
ever support Map
?
Is there a workaround in the meantime to be able to achieve similar functionality with dry-schema
?
alassek
December 18, 2024, 1:59am
5
Nobody is working on it right now, but a big reorganization is coming . This will hopefully present an opportunity to address some long-standing issues.