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
errorsIDictionary<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
messagestringThe 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
messagestringThe error message that explains the reason for the exception.
innerExceptionExceptionThe 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
errorCodestringThe error code to associate with the exception.
messagestringThe 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
errorCodestringThe error code to associate with the exception.
messagestringThe error message that explains the reason for the exception.
innerExceptionExceptionThe 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
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
fieldNamestringThe name of the field with invalid format.
expectedFormatstringThe 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
fieldNamestringThe name of the field with out-of-range value.
minobjectThe minimum allowed value.
maxobjectThe 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
fieldNamestringThe 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.