Table of Contents

Class ValidationException

Namespace
Excalibur.Dispatch.Exceptions
Assembly
Excalibur.Dispatch.dll

Exception thrown when validation errors occur.

public sealed class ValidationException : DispatchException, ISerializable
Inheritance
ValidationException
Implements
Inherited Members
Extension Methods

Constructors

ValidationException()

Initializes a new instance of the ValidationException class.

public ValidationException()

ValidationException(IDictionary<string, string[]>)

Initializes a new instance of the ValidationException class with validation errors.

public ValidationException(IDictionary<string, string[]> errors)

Parameters

errors IDictionary<string, string[]>

The validation errors.

ValidationException(string)

Initializes a new instance of the ValidationException class with a specified error message.

public ValidationException(string message)

Parameters

message string

The error message that explains the reason for the exception.

ValidationException(string, Exception?)

Initializes a new instance of the ValidationException class with a message and inner exception.

public ValidationException(string message, Exception? innerException)

Parameters

message string

The error message that explains the reason for the exception.

innerException Exception

The exception that is the cause of the current exception.

ValidationException(string, string)

Initializes a new instance of the ValidationException class with an explicit error code.

public ValidationException(string errorCode, string message)

Parameters

errorCode string

The error code to associate with the exception.

message string

The error message that explains the reason for the exception.

ValidationException(string, string, Exception?)

Initializes a new instance of the ValidationException class with an explicit error code and inner exception.

public ValidationException(string errorCode, string message, Exception? innerException)

Parameters

errorCode string

The error code to associate with the exception.

message string

The error message that explains the reason for the exception.

innerException Exception

The exception that is the cause of the current exception.

Properties

ValidationErrors

Gets the validation errors by field name.

public IDictionary<string, string[]> ValidationErrors { get; }

Property Value

IDictionary<string, string[]>

The current ValidationErrors value.

Methods

AddError(string, string)

Adds a validation error for a field.

public ValidationException AddError(string fieldName, string errorMessage)

Parameters

fieldName string

The field name.

errorMessage string

The error message.

Returns

ValidationException

The current exception instance for fluent configuration.

InvalidFormat(string, string)

Creates a validation exception for an invalid format.

public static ValidationException InvalidFormat(string fieldName, string expectedFormat)

Parameters

fieldName string

The name of the field with invalid format.

expectedFormat string

The expected format.

Returns

ValidationException

A new ValidationException instance.

OutOfRange(string, object, object)

Creates a validation exception for an out-of-range value.

public static ValidationException OutOfRange(string fieldName, object min, object max)

Parameters

fieldName string

The name of the field with out-of-range value.

min object

The minimum allowed value.

max object

The maximum allowed value.

Returns

ValidationException

A new ValidationException instance.

RequiredField(string)

Creates a validation exception for a required field.

public static ValidationException RequiredField(string fieldName)

Parameters

fieldName string

The name of the required field.

Returns

ValidationException

A new ValidationException instance.

ToDispatchProblemDetails()

Converts the exception to a Dispatch-specific problem details representation with validation errors.

public override DispatchProblemDetails ToDispatchProblemDetails()

Returns

DispatchProblemDetails

A DispatchProblemDetails instance including validation errors.