Table of Contents

Class ScalarValueValidationMiddleware

Namespace
Trellis.Asp
Assembly
Trellis.Asp.dll

Middleware that creates a validation error collection scope for each request. This enables ValidatingJsonConverter to collect validation errors across the entire request deserialization process.

public sealed class ScalarValueValidationMiddleware
Inheritance
ScalarValueValidationMiddleware
Inherited Members
Extension Methods

Examples

Registering the middleware in Program.cs:

app.UseScalarValueValidation();
// ... other middleware
app.MapControllers();

Remarks

This middleware should be registered early in the pipeline, before any middleware that might deserialize JSON request bodies.

For each request:

Constructors

ScalarValueValidationMiddleware(RequestDelegate)

Creates a new instance of ScalarValueValidationMiddleware.

public ScalarValueValidationMiddleware(RequestDelegate next)

Parameters

next RequestDelegate

The next middleware in the pipeline.

Methods

InvokeAsync(HttpContext)

Invokes the middleware, wrapping the request in a validation scope.

public Task InvokeAsync(HttpContext context)

Parameters

context HttpContext

The HTTP context for the request.

Returns

Task