title: Optional POST parameters in Elixir Phoenix
body: <p>I have a phoenix route that I want to POST some form data to, however there are about 4 fields of the form that are optional (the form is constructed by the end user and therefore these fields may not exist in the POST payload)</p>
  
  <p>In the Phoenix controller for the route, how would you handle this?</p>
  
  <p>For example:</p>
  
  <p>My form has</p>
  
  <pre><code>Field1,
  Field2
  Field3 (optional)
  Field4 (optional)
  Field5 (optional)
  </code></pre>
  
  <p>And POSTing the form must always have <code>Field1</code> and <code>Field2</code> but can have any combination of the other fields.</p>
  
  <p>so my controller code so far is like this:</p>
  
  <pre><code>def create(conn, %{"field1" =&gt; field1, "field2" =&gt; field2) do
  end
  </code></pre>
  
  <p>How do I make the other 3 optional? If I add them all in then they will be required and I don't want to have to make a function for each of the potential submitted forms as it seems overkill.</p>