Table of Contents

Interface IErrorContainer

Namespace
EasySoftware.Abstractions
Assembly
EasySoftware.Abstractions.dll

Stores validation errors, either for the whole object or for individual properties.

public interface IErrorContainer

Remarks

Errors that belong to the whole object are stored under the Empty key.

Properties

Errors

Gets or sets all errors, keyed by property name.

IReadOnlyDictionary<string, IEnumerable<string>> Errors { get; set; }

Property Value

IReadOnlyDictionary<string, IEnumerable<string>>

Remarks

Object-level errors use the Empty key. Setting this property replaces the current errors with a copy of the given ones.

HasErrors

Gets a value indicating whether the container holds at least one error.

bool HasErrors { get; }

Property Value

bool

Methods

AddError(string)

Adds an object-level error that is not tied to a specific property.

void AddError(string errorMessage)

Parameters

errorMessage string

The error message to add.

AddError(string, string)

Adds an error for the specified property.

void AddError(string propName, string errorMessage)

Parameters

propName string

The property name, or null or empty for an object-level error.

errorMessage string

The error message to add.

ClearErrors()

Removes all errors.

void ClearErrors()

ClearErrors(string)

Removes all errors of the specified property.

void ClearErrors(string propName)

Parameters

propName string

The property name, or null or empty for object-level errors.

CloneErrors(IErrorContainer)

Replaces the current errors with a copy of the errors of another container.

void CloneErrors(IErrorContainer other)

Parameters

other IErrorContainer

The container to copy the errors from.