title: How to manually validate a model with attributes?
body: <p>I have a class called <code>User</code> and a property <code>Name</code></p>
  
  <pre><code>public class User
  {
      [Required]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>And I want to validate it, and if there are any errors add to the controller's <code>ModelState</code> or instantiate another modelstate...</p>
  
  <pre><code>[HttpPost]
  public ActionResult NewUser(UserViewModel userVM)
  {
      User u = new User();
      u.Name = null;
  
      /* something */
  
      // assume userVM is valid
      // I want the following to be false because `user.Name` is null
      if (ModelState.IsValid)
      {
          TempData["NewUserCreated"] = "New user created sucessfully";
  
          return RedirectToAction("Index");
      }
  
      return View();
  }
  </code></pre>
  
  <p>The attributes works for <code>UserViewModel</code>, but I want to know how to validate a class without posting it to an action.</p>
  
  <p>How can I accomplish that?</p>