ValidationModule.cs 855 B

123456789101112131415161718192021222324
  1. using FluentValidation;
  2. namespace WebTemplate.ServerAspects.Validation;
  3. /// <summary>
  4. /// For minimal APIs, you can just add the <see cref="ValidationFilter{T}"/> to any mapped endpoint by doing something
  5. /// like
  6. /// <code>
  7. /// .AddEndpointFilter&lt;ValidationFilter&lt;MyRequest&gt;&gt;()
  8. /// </code>
  9. /// </summary>
  10. public class ValidationModule : IAppConfigurationModule
  11. {
  12. public void ConfigureServices(IServiceCollection services, IConfigurationRoot config)
  13. {
  14. // If you add a validator as described in https://github.com/FluentValidation/FluentValidation?tab=readme-ov-file
  15. // that validator should automatically be registered with this.
  16. services.AddValidatorsFromAssemblyContaining(typeof(ValidationModule));
  17. }
  18. public void ConfigureApplication(WebApplication app)
  19. {
  20. }
  21. }