title: How to respond on pydantic instantiation errors
body: <p>I receive signals ...</p>
  <pre><code>from pydantic import BaseModel
  class Signal(BaseModel):        
      provider_id: str
      sequence_id: Optional[int]
  </code></pre>
  <p>... on a fastapi endpoint. They perfectly map/deserialize the json into the class.</p>
  <pre><code>@router.post(&quot;/signal&quot;)
  async def receive_signal(signal: Signal, tags=[&quot;signal&quot;]):
     #do something
  </code></pre>
  <p>How do I respond with an error on that POST request IF the request omits a mandatory attribute of the signal? Let's say the provider_id. What is the best practice and state of the art? (I would not know where to catch that exception because the deserialization happens before the code of the <code>receive_signal</code> method is invoked.)</p>
  <p>I would like to return the following json:
  { &quot;result&quot;: &quot;error&quot;, &quot;response&quot;: &quot;provider_id was not provided&quot;}</p>