Table of Contents

Class ValidationResult

Namespace
Admonish
Assembly
Admonish.dll

Represents a collection of errors accumulated during validation.

public class ValidationResult
Inheritance
ValidationResult
Inherited Members
Extension Methods

Constructors

ValidationResult(Func<ValidationResult, Exception>)

Initializes a new instance of the ValidationResult class with the specified validation exception factory.

public ValidationResult(Func<ValidationResult, Exception> exceptionFactory)

Parameters

exceptionFactory Func<ValidationResult, Exception>

When called, creates an exception to throw when a validation error occurs.

Fields

NoKey

The default key with which errors are associated when no key is specified.

public const string NoKey = "_"

Field Value

string

Properties

Success

A flag indicating whether validation was successful.

public bool Success { get; }

Property Value

bool

Methods

AddError(string)

Adds the specified error message to the collection.

public ValidationResult AddError(string error)

Parameters

error string

The error message.

Returns

ValidationResult

The validation result.

AddError(string, string)

Adds the specified error message to the collection and associates it with the specified key.

public ValidationResult AddError(string key, string error)

Parameters

key string

The key to associate the error with.

error string

The error message.

Returns

ValidationResult

The validation result.

ThrowIfInvalid()

Throws an exception if there were errors during validation.

public ValidationResult ThrowIfInvalid()

Returns

ValidationResult

The validation result.

ToDictionary()

Gets the dictionary of accumulated errors.

public IDictionary<string, string[]> ToDictionary()

Returns

IDictionary<string, string[]>

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.