title: Pydantic - Validation Does not Happen
body: <p>I am quite new to using Pydantic.</p>
  <p>The Issue I am facing right now is that the Model Below is not raising the Expected Exception when the value is out of range.</p>
  <p>For example, if you pass -1 into this model it should ideally raise an HTTPException. but nothing happens</p>
  <p>I am not sure where I might be going wrong.</p>
  <p>Any Advice would be great.</p>
  <pre><code>class GetInput:
      &quot;&quot;&quot;
      for the fields endpoint
      &quot;&quot;&quot;
  
      def __init__(self,
                   rank: Optional[int] = None,
                   interval: Optional[int] = None):
  
          self.rank = rank
          self.interval = interval
  
      @validator('rank')
      def check_if_rank_in_range(cls, v):
          &quot;&quot;&quot;
          check if input rank is within range
          &quot;&quot;&quot;
          if not 0 &lt; v &lt; 1000001:
  
              raise HTTPException(
                  status_code=400, detail=&quot;Rank Value Must be within range (0,1000000)&quot;)
          return v
  
      @validator('interval')
      def check_if_interval_in_range(cls, v):
          &quot;&quot;&quot;
          check if input rank is within range
          &quot;&quot;&quot;
          if not 0 &lt; v &lt; 1000001:
  
              raise HTTPException(
                  status_code=400, detail=&quot;Interval Value Must be within range (0,1000000)&quot;)
          return v
  
  </code></pre>
  <p>The FastAPI Endpoint</p>
  <pre><code>@router.get('fields/',status_code=200)
  def get_data(params: GetInput = Depends()):
      
      if params.rank:
          result = get_info_by_rank(params.rank)
  
      elif params.interval:
  
          result = get_info_by_interval(params.interval)
      
      return result
  </code></pre>