# Support for Hash.of

**URL:** <https://discourse.dry-rb.org/t/support-for-hash-of/761>\
**Category:** dry-types\
**Created:** [April 26, 2019, 6:07am UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761 "2019-04-26T06:07:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![waiting-for-dev](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/waiting-for-dev/32/71_2.png) [@waiting-for-dev](https://discourse.dry-rb.org/u/waiting-for-dev)\
**Post date:** [April 26, 2019, 6:07am UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761/1 "2019-04-26T06:07:14Z")

</div>

In the same vain that it is possible to specify a `Types::Strict::Array.of(Types::Strict::String)`, it would be nice to support specifying the expected types for keys and values in a Hash. Something like `Types::Strict::Hash.of(keys: Types::Strict::Symbol, values: Types::Strict::String)`.

It is already possible to define a schema for Hash, but I find a lot of times with the situation where I’m going to use a Hash with unknown keys but with expected key/value types. What do you think?

---

<div class="post-metadata">

**Author:** ![timriley](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/timriley/32/25_2.png) [@timriley](https://discourse.dry-rb.org/u/timriley)\
**Post date:** [April 27, 2019, 11:08pm UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761/2 "2019-04-27T23:08:36Z")

</div>

@waiting-for-dev I think you might be describing [`Types::Hash.map`](https://dry-rb.org/gems/dry-types/map/)?

---

<div class="post-metadata">

**Author:** ![waiting-for-dev](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/waiting-for-dev/32/71_2.png) [@waiting-for-dev](https://discourse.dry-rb.org/u/waiting-for-dev)\
**Post date:** [April 28, 2019, 6:34am UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761/3 "2019-04-28T06:34:41Z")

</div>

@timriley I think you are right 😄 I completely missed that part of the docs. Sorry for the noise and thanks for pointing me toward the right resource 😄

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/solnic/32/779_2.png) [@solnic](https://discourse.dry-rb.org/u/solnic)\
**Post date:** [April 29, 2019, 7:07am UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761/4 "2019-04-29T07:07:09Z")

</div>

Quite recently somebody asked about this and I said “there’s no such thing” and then Nikita showed up and said "well, actually…there’s `Types::Map`". So, yeah 😆

---

<div class="post-metadata">

**Author:** ![waiting-for-dev](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/waiting-for-dev/32/71_2.png) [@waiting-for-dev](https://discourse.dry-rb.org/u/waiting-for-dev)\
**Post date:** [April 29, 2019, 9:53am UTC](https://discourse.dry-rb.org/t/support-for-hash-of/761/5 "2019-04-29T09:53:28Z")

</div>

It was my fault for sure because it is very well documented and the documentation is very accessible, but maybe we have a little naming inconsistency here… I think it would be more consistent to name `Array.of` and `Hash.of`, or something like `Array.list` and `Hash.map` 🙂
