title: MVC 4 Range validator not accepting minimum value
body: <p>I need to use Range Validator in my asp.net mvc 4 project. In view model I added:</p>
  
  <pre><code>[Range(0, int.MaxValue, ErrorMessage = "The Region field is required.")]
  public int Region { get; set; }
  </code></pre>
  
  <p>And in controller i checked it by <code>ModelState.IsValid</code>.</p>
  
  <p>The problem is ModelState don't accept <code>0</code> as a properly value - it's strange because I set range <strong>from</strong> <code>0</code> to <code>max int</code>, so I thought that <code>0</code> belong to collection (like in MVC 5 if I remember). Am I wrong or it's just a bug? Any others value is reading properly (<code>-1</code> is not accepting and <code>1001</code> is ok).</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p><a href="https://i.stack.imgur.com/mwoNA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mwoNA.png" alt="Debug 1"></a>
  <a href="https://i.stack.imgur.com/G6i12.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G6i12.png" alt="enter image description here"></a></p>
  
  <p>(Like you see in above pictures I don't anything with my model before I not check if model is valid).</p>
  
  <p>Register method:</p>
  
  <pre><code>[HttpPost]
  [AllowAnonymous]
  [ValidateAntiForgeryToken]
  public ActionResult Register(RegisterModel model)
  {
      if (ModelState.IsValid)
      {
          //I was never here! Always ModelState.IsValid returns false
      }
  
      // If we got this far, something failed, redisplay form
      ViewBag.Regions = _database.Department.ToList();
      return View(model);
  }
  </code></pre>
  
  <p>Full RegisterViewModel class:</p>
  
  <pre><code>public class RegisterModel
  {
      [Required]
      [Display(Name = "User name")]
      public string UserName { get; set; }
  
      [Required]
      [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
      [DataType(DataType.Password)]
      [Display(Name = "Password")]
      public string Password { get; set; }
  
      [DataType(DataType.Password)]
      [Display(Name = "Confirm password")]
      [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
      public string ConfirmPassword { get; set; }
  
      [Required]
      [Display(Name = "Role")]
      public int Role { get; set; }
  
      [Range(0, int.MaxValue, ErrorMessage = "The Region field is required.")]
      [Display(Name = "Region")]
      public int Region { get; set; }
  }
  </code></pre>
  
  <p>Register view:</p>
  
  <pre><code>&lt;fieldset&gt;
          &lt;legend&gt;Registration Form&lt;/legend&gt;
          &lt;ol&gt;
              &lt;li&gt;
                  @Html.LabelFor(m =&gt; m.UserName)
                  @Html.TextBoxFor(m =&gt; m.UserName)
              &lt;/li&gt;
              &lt;li&gt;
                  @Html.LabelFor(m =&gt; m.Password)
                  @Html.PasswordFor(m =&gt; m.Password)
              &lt;/li&gt;
              &lt;li&gt;
                  @Html.LabelFor(m =&gt; m.ConfirmPassword)
                  @Html.PasswordFor(m =&gt; m.ConfirmPassword)
              &lt;/li&gt;
              &lt;li&gt;
                  @Html.LabelFor(m =&gt; m.Role)
                  &lt;select id="Role" name="Role" data-val-required="The Role field is required." data-val="true"&gt;
                      &lt;option value=""&gt;Choose role for user&lt;/option&gt;
                      &lt;option value="1"&gt;Administrator&lt;/option&gt;
                      &lt;option value="2"&gt;Inspector&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/li&gt;
              &lt;li id="region-section"&gt;
                  @Html.LabelFor(m =&gt; m.Region)
                  &lt;select id="Region" name="Region" data-val-required="The Region field is required." data-val="true"&gt;
                      &lt;option value="" selected&gt;Choose region&lt;/option&gt;
                      @foreach (var item in ViewBag.Regions)
                      {
                          &lt;option value="@item.Id"&gt;@item.Name&lt;/option&gt;
                      }
                  &lt;/select&gt;
              &lt;/li&gt;
          &lt;/ol&gt;
          &lt;input type="submit" value="Register" /&gt;
      &lt;/fieldset&gt;
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>According to @pilotcam advice I have used <code>ValidateModel()</code> function. In debug mode I got HResult: <code>-2146233079</code> - I was trying convert it into System Error Code (<code>-2146233079 &amp; 0xFFFF = 5385</code>) but is not a part of <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381%28v=vs.85%29.aspx" rel="nofollow noreferrer">System Error Codes list</a>.</p>