# what if you wanted to require some hash keys \*and\* keep extra keys?

**URL:** <https://discourse.dry-rb.org/t/what-if-you-wanted-to-require-some-hash-keys-and-keep-extra-keys/1678>\
**Category:** dry-types\
**Created:** [May 24, 2023, 10:54pm UTC](https://discourse.dry-rb.org/t/what-if-you-wanted-to-require-some-hash-keys-and-keep-extra-keys/1678 "2023-05-24T22:54:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![doriantaylor](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/doriantaylor/32/385_2.png) [@doriantaylor](https://discourse.dry-rb.org/u/doriantaylor)\
**Post date:** [May 24, 2023, 10:54pm UTC](https://discourse.dry-rb.org/t/what-if-you-wanted-to-require-some-hash-keys-and-keep-extra-keys/1678/1 "2023-05-24T22:54:36Z")

</div>

How would one formulate a hash schema that requires a certain set of keys (and presumably type-tests and/or coerces them) but also doesn’t drop unspecified keys?

Imagine I have a config file, let’s say it’s YAML (the format is not important).

```yaml
sources:
  -
    driver: Foo
    param1: bar
    param2: something else
targets:
  named1:
    driver: FileSystem
    dir: /var/lib/whatever

```

I am looking for how to do some `Types::Hash` declaration that will:

- convert the keys to symbols (plus `.downcase.tr_s('_- ', ?_)`)
- stipulate a `driver` key with type
- _not_ throw out the other keys.

I can’t tell how to do that in the docs.

Furthermore:

- it seems that I can do `Hash.map(KeyType, ValType)` but not combine that with `.schema`
- if I do `Hash.schema({}).with_key_transform &proc` and try to extend that, it throws out the other keys.
