Код: Выделить всё
public abstract class GenericValidator : AbstractValidator
{
///
/// Validates a string property to ensure it is not null, not empty, and meets a minimum length requirement.
///
///
The string value to validate.
/// The name of the property being validated.
/// The minimum length the string must have.
/// The error message format.
/// Returns a rule builder for further customization.
protected IRuleBuilderOptions ValidateString(
Func propertyValue,
string propertyName,
int minLength = 0,
string errorMessage = "{PropertyName} is invalid.")
{
return *RuleFor*(propertyValue)
.NotNull().WithMessage($"{propertyName} cannot be null.")
.NotEmpty().WithMessage($"{propertyName} cannot be empty.")
.MinimumLength(minLength).WithMessage($"{propertyName} must be at least {minLength} characters long.")
.WithMessage(errorMessage);
}
}
"CS0411 Аргументы типа для метода 'AbstractValidator.RuleFor(Expression)' не может быть выведено из использования. Попробуйте указать аргументы типа явно" для метода "RuleFor".
У меня ограниченное знакомство с Generic. Я пытался решить то же самое, но не смог.
Любая информация будет полезна. Для этого я использую пакет проверки Fluent версии 11*.
Что нужно сделать, чтобы устранить ошибку?
Подробнее здесь: https://stackoverflow.com/questions/790 ... ng-generic
Мобильная версия