protected override ValidationResult IsValid(object value, ValidationContext validationContext) { ErrorMessageTranslationService errorTranslation = validationContext.GetService(typeof(ErrorMessageTranslationService)) as ErrorMessageTranslationService; return(IbanValidator.Validate(value as string) ? ValidationResult.Success : new ValidationResult(errorTranslation.GetLocalizedError(_errorMessage))); }
private string GetErrorMessage(ValidationContext validationContext) { if (string.IsNullOrEmpty(ErrorMessage)) { return "Invalid CPF"; } ErrorMessageTranslationService errorTranslation = validationContext.GetService(typeof(ErrorMessageTranslationService)) as ErrorMessageTranslationService; return errorTranslation.GetLocalizedError(ErrorMessage); }