Improvement of the repetition with generics

I'm just wondering if there's a way to reduce this code reuse using generic drugs. It seems like I am producing a lot of redundant code this way. To give a background, I have three types of requests that are sent to my API. Each of these requests then uses a Validator class to validate and create one ValidationResult, The problem is that I have to make a lot of similar boilerplates for every kind of request.


public class CreateRequest { }
public class UpdateRequest { }
public class DeleteRequest { }

There are no similarities between class characteristics, so I did not bother to list them here.


Use these FluentValidation Therefore, the constructor contains the rule definitions for each property. AbstractValidator is of FluentValidation and the interface is for DI purposes only.

public class CreateRequestValidator : AbstractValidator, ICreateRequestValidator 
public class UpdateRequestValidator : AbstractValidator, IUpdateRequestValidator
public class DeleteRequestValidator : AbstractValidator, IDeleteRequestValidator


Each interface follows a pattern that contains a method Validate that picks up the parameter of its request type and returns a ValidationResult, For the sake of brevity, I'll just add one thing:

public interface ICreateRequestValidator
    ValidationResult Validate(CreateRequest instance);

Request validator

I have a separate class passed to each validator because I've been injected with too many dependencies that only increase for each added request.

public class RequestValidator : IRequestValidator
    private readonly ICreateRequestValidator _createRequestValidator;
    private readonly IUpdateRequestValidator _updateRequestValidator;
    private readonly IDeleteRequestValidator _deleteRequestValidator;

    public RequestValidator(ICreateRequestValidator createRequestValidator, IUpdateRequestValidator updateRequestValidator, IDeleteRequestValidator deleteRequestValidator)
        _createRequestValidator = createRequestValidator;
        _updateRequestValidator = updateRequestValidator;
        _deleteRequestValidator = deleteRequestValidator;

    public ValidationResult ValidateCreateRequest(CreateRequest request)
        return _createRequestValidator.Validate(request);

    public ValidationResult ValidateUpdateRequest(UpdateRequest request)
        return _updateRequestValidator.Validate(request);

    public ValidationResult ValidateDeleteRequest(DeleteRequest request)
        return _deleteRequestValidator.Validate(request);

I hope that I can do something in this last hour.