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
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
Methods
AddError(string)
Adds an object-level error that is not tied to a specific property.
void AddError(string errorMessage)
Parameters
errorMessagestringThe error message to add.
AddError(string, string)
Adds an error for the specified property.
void AddError(string propName, string errorMessage)
Parameters
propNamestringThe property name, or null or empty for an object-level error.
errorMessagestringThe error message to add.
ClearErrors()
Removes all errors.
void ClearErrors()
ClearErrors(string)
Removes all errors of the specified property.
void ClearErrors(string propName)
Parameters
CloneErrors(IErrorContainer)
Replaces the current errors with a copy of the errors of another container.
void CloneErrors(IErrorContainer other)
Parameters
otherIErrorContainerThe container to copy the errors from.