title: How to efficiently rename an attribute in an ecto changeset before it's being used
body: <p>I have come up with the following solution which I call before the cast:</p>
  
  <pre><code>attrs = payload_fields_to_payload(attrs)
  </code></pre>
  
  <p>The issue was that the incoming attrs can be atom-based, but doesn't have to be. So is there any faster or cleaner way than what I'm doing here? I'm just renaming a key in the attributes. It seems to be lots of code for this task.</p>
  
  <pre><code>def payload_fields_to_payload(attrs) do
      attrs = cond do
        Map.has_key?(attrs, "payload_fields") -&gt;
          Map.put(attrs, "payload", Map.get(attrs, "payload_fields"))
        Map.has_key?(attrs, :payload_fields) -&gt;
          Map.put(attrs, :payload, Map.get(attrs, :payload_fields))
        true -&gt; attrs
      end
      attrs
  end
  </code></pre>