Class ValidationApiExtensions
- Namespace
- Olve.MinimalApi
- Assembly
- Olve.MinimalApi.dll
Extension methods to add validation filters for minimal API endpoints.
public static class ValidationApiExtensions
- Inheritance
-
ValidationApiExtensions
- Inherited Members
Methods
WithValidation<TRequest, TValidator>(RouteHandlerBuilder)
Adds a validation filter that creates a new TValidator to validate requests of type TRequest.
public static RouteHandlerBuilder WithValidation<TRequest, TValidator>(this RouteHandlerBuilder builder) where TValidator : IValidator<TRequest>, new()
Parameters
builderRouteHandlerBuilderThe route handler builder to configure.
Returns
- RouteHandlerBuilder
The configured RouteHandlerBuilder with validation filter.
Type Parameters
TRequestThe type of requests to validate.
TValidatorThe validator type to instantiate.
WithValidation<TRequest, TValidator>(RouteHandlerBuilder, TValidator)
Adds a validation filter using the specified TValidator instance to validate requests of type TRequest.
public static RouteHandlerBuilder WithValidation<TRequest, TValidator>(this RouteHandlerBuilder builder, TValidator validator) where TValidator : IValidator<TRequest>
Parameters
builderRouteHandlerBuilderThe route handler builder to configure.
validatorTValidatorThe validator instance to use.
Returns
- RouteHandlerBuilder
The configured RouteHandlerBuilder with validation filter.
Type Parameters
TRequestThe type of requests to validate.
TValidatorThe type of the validator.