namespace SatelliteProvider.Api.Validators;

// AZ-795: ergonomic extension method for opting an endpoint into
// FluentValidation. Applied at MapPost/MapGet registration time:
//
//   app.MapPost("/api/satellite/tiles/inventory", GetTilesInventory)
//      .WithValidation<TileInventoryRequest>();
//
// One line per endpoint; no per-handler try/catch boilerplate; uniform
// RFC 7807 error shape — see `_docs/02_document/contracts/api/error-shape.md`.
public static class ValidationEndpointFilterExtensions
{
    public static RouteHandlerBuilder WithValidation<T>(this RouteHandlerBuilder builder)
        where T : class
    {
        builder.AddEndpointFilter<ValidationEndpointFilter<T>>();
        return builder;
    }
}
