Class ValidationContext<T>
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public class ValidationContext<T> : ValidationContext
Type Parameters
| Name | Description |
|---|---|
| T |
Properties
Instance
Declaration
public static ValidationContext<T> Instance { get; }
Property Value
| Type | Description |
|---|---|
| ValidationContext<T> |
Methods
AddError(Expression<Func<T, object?>>, string, string?, Severity)
adds an error message for the specified property of the request dto
Declaration
public void AddError(Expression<Func<T, object?>> property, string errorMessage, string? errorCode = null, Severity severity = Severity.Error)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, object>> | property | the property to add the error message for |
| string | errorMessage | the error message |
| string | errorCode | the error code associated with the error |
| Severity | severity | the severity of the error |
ThrowError(Expression<Func<T, object?>>, string, int?)
adds an error message for the specified property of the request dto and sends back a 400 bad request with error details immediately interrupting handler execution flow. no execution will continue past this call.
Declaration
public void ThrowError(Expression<Func<T, object?>> property, string errorMessage, int? statusCode = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, object>> | property | the property to add the error message for |
| string | errorMessage | the error message |
| int? | statusCode | an optional status code to be used when building the error response |
ThrowError(Expression<Func<T, object?>>, string, string, Severity, int?)
adds an error message for the specified property of the request dto and sends back a 400 bad request with error details immediately interrupting handler execution flow. no execution will continue past this call.
Declaration
public void ThrowError(Expression<Func<T, object?>> property, string errorMessage, string errorCode, Severity severity = Severity.Error, int? statusCode = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, object>> | property | the property to add the error message for |
| string | errorMessage | the error message |
| string | errorCode | the error code associated with the error |
| Severity | severity | the severity of the error |
| int? | statusCode | an optional status code to be used when building the error response |