title: How to create custom validation attribute?
body: <p>I am trying to create a custom validation attribute.</p>
  
  <pre><code>public class PhoneValidator : ValidationAttribute
  {
      public override bool IsValid(object value)
      {
          return new RegularExpressionAttribute(@"^[+0]\d+").IsValid(Convert.ToString(value).Trim());
      }
  }
  </code></pre>
  
  <p>And I use this to use</p>
  
  <pre><code>[PhoneValidator]
  public string PhoneNumber { get; private set; }
  </code></pre>
  
  <p>I copied it from a website, in theory this should work. But I couldn't make it work.</p>