title: Model validation not working with Razor Page & PageModel
body: <p>I have a Razor Page that has a tag to print out an error message, and also prints the walue of <code>ModelState.IsValid</code>.</p>
  
  <pre class="lang-razor prettyprint-override"><code>@page
  @model IndexModel
  
  &lt;form asp-page="Index" method="get"&gt;
      &lt;input asp-for="Message"/&gt;
      &lt;span asp-validation-for="Message"&gt;&lt;/span&gt;
      &lt;input type="submit" value="Submit"/&gt;
  &lt;/form&gt;
  
  &lt;p&gt;ModelState.IsValid = @Model.ModelIsValid&lt;/p&gt;
  </code></pre>
  
  <p>The PageModel is annotated with a regex requirement:</p>
  
  
  
  <pre><code>public class IndexModel : PageModel
  {
      [FromQuery]
      [RegularExpression("^[A-Za-z]*$")]
      public string Message { get; set; }
  
      public bool ModelIsValid { get; private set; }
  
      public void OnGet()
      {
          ModelIsValid = ModelState.IsValid;
      }
  }
  </code></pre>
  
  <p>The model is always valid though, regardless of what I set the <code>Message</code> to or don't add it at all.</p>
  
  <p><strong>NB</strong> <code>Message</code> is correctly populated.</p>
  
  <p><strong>NB 2</strong> Neither adding <code>[Required(AllowEmptyStrings = false)]</code> or replacing <code>[FromQuery]</code> with <code>[BindProperty(SupportsGet = true)]</code> changes the behaviour.</p>
  
  <p>Why aren't my annotations being effective?</p>
  
  <p>I've shared the full project here:  <a href="https://1drv.ms/u/s!Au6otEu-6FtC2VFoLNCTDydGUSIR" rel="nofollow noreferrer">https://1drv.ms/u/s!Au6otEu-6FtC2VFoLNCTDydGUSIR</a></p>