# Pattern Matching Map

**URL:** <https://forum.elixirforum.com/t/pattern-matching-map/32064>\
**Category:** Questions\
**Tags:** pattern-matching, phoenix, beginners-questions, elixir-map, help\
**Created:** [June 3, 2020, 9:50am UTC](https://forum.elixirforum.com/t/pattern-matching-map/32064 "2020-06-03T09:50:44Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![amnu3387](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@amnu3387](https://forum.elixirforum.com/u/amnu3387)\
**Post date:** [June 3, 2020, 11:54am UTC](https://forum.elixirforum.com/t/pattern-matching-map/32064/6 "2020-06-03T11:54:09Z")

</div>

There’s really no way of knowing what that pattern match means at compile time, the options I see is to either use `is_map_key` as @qhwa mentions, like:

```elixir
def update(conn, %{"expense_id" => id, "name" => _name} = params
) when is_map_key(params, "language") or is_map_key(params, "another_key") do ....

```

But you’ll probably have to handle then, down the line, which param was actually passed, so you don’t gain that much other than validating that at least one of those keys is present.

Or having multiple `update` function definitions, one for each expected key, pattern matching the exact key on each one (then in the body of `update` you’ll know exactly which one you’re dealing with), or to have a function that validates the map, called inside the `update` controller action and take it from there.

Without knowing what is the whole intended flow not sure what would be the best option.

---

_[View the full topic](https://forum.elixirforum.com/t/pattern-matching-map/32064)._
