title: ASP.NET Core custom validation attribute localization
body: <p>I'm trying to implement localization in a custom validation attribute in asp.net core 1.0. This is my simplified viewmodel:</p>
  
  <pre><code>public class EditPasswordViewModel
  {
      [Required(ErrorMessage = "OldPasswordRequired")]
      [DataType(DataType.Password)]
      [CheckOldPassword(ErrorMessage = "OldPasswordWrong")]
      public string OldPassword { get; set; }
  }
  </code></pre>
  
  <p>The localization of "OldPasswordRequired" is working fine. However the localization of my custom attribute is not working and returns always "OldPasswordWrong" message. This is the code:</p>
  
  <pre><code>public class CheckOldPasswordAttribute : ValidationAttribute
  {
      protected override ValidationResult IsValid(object classInstance, ValidationContext validationContext)
      {                   
          if (oldPasswordSaved == oldPasswordTyped) //simplified
          {
              return ValidationResult.Success;
          }
          else
          {
              string errorMessage = FormatErrorMessage(ErrorMessageString);
              return new ValidationResult(errorMessage);
          }
      }
  
  }
  </code></pre>
  
  <p>ErrorMessageString is always "OldPasswordWrong" and FormatErrorMessage returns always "OldPasswordWrong". What am I doing wrong?
  I'm using the new asp.net core data annotations localizations, so I'm not using ErrorMessageResourceName and ErrorMessageResourceType attributes (I don't have any ViewModel.Designer.cs).</p>