title: Pydantic input model for partial updates
body: <p>I am using Pydantic to validate data inputs in a server. Pydantic models:</p>
  <ul>
  <li>User: for common fields</li>
  <li>UserIn: user input data to create new account</li>
  <li>UserInDB: to hash password and include extra fields like <code>created_at</code></li>
  <li>UserOut: to output created/updated user data</li>
  </ul>
  <p>Now how can I utilize the model <code>UserIn</code> for user account partial updates? so that <code>None</code> fields are excluded. Or do I have to rewrite it again and make every field optional?</p>
  <pre><code>class User(BaseModel):
  
      name_first :          str = Field(...)
      name_last :           Optional[str] = None
      mobile :              int = Field(..., description=&quot;It has to be 8 digits and starts with either 9 or 7&quot;, example=&quot;99009900&quot;)
      
      email :               Optional[EmailStr] = None
      
      gender:               Literal['m', 'f'] = Field(..., example=&quot;m&quot;)
      birth_date:           datetime.date
      preferred_language :  Literal['ar', 'en'] = Field(..., example=&quot;ar&quot;)
      newsletter :          bool = Field(...)
  
  
      @validator('mobile')
      def number_has_to_start_with_9_or_7(cls, v):
          if str(v)[:1] !=&quot;9&quot; and str(v)[:1] !=&quot;7&quot;:
              raise ValueError('Mobile number must start with 9 or 7')
          if len(str(v)) !=8:
              raise ValueError('Mobile number must be 8 digits')
          return v
  
  
  class UserIn(User):
      password: str = Field(...)
  
  class UserInDB(UserIn):
      mobile_otp:           int = Field(...)
      bitrole:              int = Field(...)
      created_at:           datetime.datetime
      updated_at:           datetime.datetime
  
  class UserOut(User):
      id:                   int
      mobile_otp:           int
      bitrole:              int
      mobile_confirmed :    bool
      email_confirmed :     bool
      disabled :            bool
      created_at:           datetime.datetime
      updated_at:           datetime.datetime
  
      class Config:
          orm_mode = True
  </code></pre>