# How to define a schema for hashes with non Symbol/String keys

**URL:** <https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659>\
**Category:** dry-validation\
**Created:** [April 19, 2023, 2:11am UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659 "2023-04-19T02:11:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![delonnewman](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/delonnewman/32/911_2.png) [@delonnewman](https://discourse.dry-rb.org/u/delonnewman)\
**Post date:** [April 19, 2023, 2:11am UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659/1 "2023-04-19T02:11:12Z")

</div>

I’m trying to validate the following shape:

```ruby
{
  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!

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/alassek/32/314_2.png) [@alassek](https://discourse.dry-rb.org/u/alassek)\
**Post date:** [April 19, 2023, 7:58pm UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659/2 "2023-04-19T19:58:09Z")

</div>

You can represent this with dry-types, like

```ruby
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.

---

<div class="post-metadata">

**Author:** ![delonnewman](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/delonnewman/32/911_2.png) [@delonnewman](https://discourse.dry-rb.org/u/delonnewman)\
**Post date:** [April 19, 2023, 9:19pm UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659/3 "2023-04-19T21:19:28Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![tylerhunt](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/tylerhunt/32/1005_2.png) [@tylerhunt](https://discourse.dry-rb.org/u/tylerhunt)\
**Post date:** [December 11, 2024, 8:51pm UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659/4 "2024-12-11T20:51:43Z")

</div>

Will `dry-schema` ever support `Map`?

Is there a workaround in the meantime to be able to achieve similar functionality with `dry-schema`?

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/alassek/32/314_2.png) [@alassek](https://discourse.dry-rb.org/u/alassek)\
**Post date:** [December 18, 2024, 1:59am UTC](https://discourse.dry-rb.org/t/how-to-define-a-schema-for-hashes-with-non-symbol-string-keys/1659/5 "2024-12-18T01:59:59Z")

</div>

Nobody is working on it right now, but [a big reorganization is coming](https://hanamirb.org/blog/2024/12/12/a-new-chapter-for-dry-rb-rom/). This will hopefully present an opportunity to address some long-standing issues.
