title: View Component with validation errors
body: <p>When i submit a form with incorrect data within a view component, my view component does not display any errors on the page. </p>
  
  <p>So is it possible for a view component to return validation errors ?</p>
  
  <h2>View Component</h2>
  
  <pre><code>&lt;div class="card-block"&gt;
      &lt;form class="form-inline-custom" asp-controller="BragOption" asp-action="Create" method="post" role="form"&gt;
          &lt;div class="form-group"&gt;
              &lt;label asp-for="CreateBragOptionViewModel.PeriodFrom"&gt;From &lt;span asp-validation-for="CreateBragOptionViewModel.PeriodFrom" class="alert-danger"&gt;&lt;/span&gt;&lt;/label&gt;
              &lt;input asp-for="CreateBragOptionViewModel.PeriodFrom" class="form-control"&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;label asp-for="CreateBragOptionViewModel.PeriodTo"&gt;To &lt;span asp-validation-for="CreateBragOptionViewModel.PeriodTo" class="alert-danger"&gt;&lt;/span&gt;&lt;/label&gt;
              &lt;input asp-for="CreateBragOptionViewModel.PeriodTo" class="form-control"&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;button type="submit" class="btn btn-block btn-primary"&gt;START VOTING PERIOD&lt;/button&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <h2>Action Controller</h2>
  
  <pre><code>[HttpPost]
      public IActionResult Create(BragOptionViewModel model)
      {
          if (! ModelState.IsValid)
          {
              return View(nameof(BragManagementController.Index), model);
          }
  
          if (! _bragOptionService.IsVotingPeriodFromValid(model.CreateBragOptionViewModel))
          {
              ModelState.AddModelError("PeriodFrom", "The date you have entered should not be in the future");
              return View(nameof(BragManagementController.Index), model);
          }
  
          if (!_bragOptionService.IsVotingPeriodToValid(model.CreateBragOptionViewModel))
          {
              ModelState.AddModelError("PeriodTo", "The date you have entered should not be in the past");
              return View(nameof(BragManagementController.Index), model);
          }
  
          _bragOptionRepository.CreateVotingPeriod(_bragOptionService.LoadBragOption(model.CreateBragOptionViewModel));
  
          return RedirectToAction(nameof(BragManagementController.Index), "BragManagement");
      }
  </code></pre>
  
  <h2>view models</h2>
  
  <pre><code>public class CreateBragOptionViewModel
  {
      [DataType(DataType.Date)]
      public DateTime PeriodFrom { get; set; }
      [DataType(DataType.Date)]
      public DateTime PeriodTo { get; set; }
  }
  
   public class BragOptionViewModel
  {
      public CreateBragOptionViewModel CreateBragOptionViewModel { get; set; }
  
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = "{MMM 0:d, yyyy}", ApplyFormatInEditMode = true)]
      public DateTime VotingPeriodTo { get; set; }
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = "{MMM 0:d, yyyy}", ApplyFormatInEditMode = true)]
      public DateTime VotingPeriodFrom { get; set; }
  }
  </code></pre>