Sooo. The sad response is: there is no way to match a single value of a keyword list, so pattern matching on the params is not possible.
Now, let’s go to your other attempts. The first guard clause you checked if the value :country was inside the changeset.errors, and changeset.errors is a keyword lists, which means it follows this pattern [{:country, "value1"}, {:area_of_residence, "value2"}], which is syntax sugared to [country: "value1", area_of_residence: "value2"]. If you want to match one of the keys, you should try :country in Keyword.keys(changeset.errors).
Well, unfortunately, that will not work on the guard clause when too. For the same reason your second attempt didn’t: there is a limited number of expressions that are allowed in guard clauses, check the list here.
So, the easiest solution you have for now is the if inside the function. I was really struggling to discover another way to do it, but couldn’t. Sorry 






















