title: Custom error message on model validation ASP.NET Core MVC
body: <p>I'm working with ASP.NET Core MVC project, in which we want to set custom message to required field with filed name instead of generic message given by framework.<br>
  For that I I have created a custom class as below:</p>
  
  <pre><code>public class GenericRequired : ValidationAttribute
  {
      public GenericRequired() : base(() =&gt; "{0} is required")
      {
  
      }
  
      public override bool IsValid(object value)
      {
          if (value == null)
          {
              return false;
          }
          string str = value as string;
          if (str != null)
          {
              return (str.Trim().Length != 0);
          }
          return true;
      }
  }
  </code></pre>
  
  <p>And using that class in a model.</p>
  
   <pre><code>[GenericRequired]
  [DisplayName("Title")]        
  public string Name { get; set; }
  </code></pre>
  
  <p>On view page:</p>
  
  <pre><code>&lt;span asp-validation-for="Name" class="text-danger"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>But message not displaying or validation doesn't work. Is there any other way to  make it work? </p>