Table of Contents

Class ValidationResult

Namespace
Mailtrap.Core.Validation
Assembly
Mailtrap.Abstractions.dll

Represents validation result.

public sealed class ValidationResult
Inheritance
ValidationResult

Constructors

ValidationResult()

Parameterless instance constructor.

public ValidationResult()

ValidationResult(IEnumerable<string>)

Creates a new ValidationResult instance from a collection of errors.

public ValidationResult(IEnumerable<string> errors)

Parameters

errors IEnumerable<string>

Collection of errors to initialize the instance with.

Properties

Errors

Gets a list of errors.

public IList<string> Errors { get; }

Property Value

IList<string>

List of errors.

IsValid

Gets a flag indicating whether validation succeeded or not.

public bool IsValid { get; }

Property Value

bool

true if current instance contains no validation errors.
false otherwise.

Methods

EnsureValidity(string)

Ensures that the current instance is valid and throws an exception, containing validation errors summary, if not.

public void EnsureValidity(string paramName)

Parameters

paramName string

Name of the parameter that have been validated.

Exceptions

ArgumentException

When the instance represents invalid result.

ToString()

Generates a single string, that contains all error messages separated by default new line separator.

public override string ToString()

Returns

string

Single string, that contains all error messages separated by default new line separator.

ToString(string)

Generates a single string, that contains all error messages separated by the specified separator.

public string ToString(string separator)

Parameters

separator string

A string to separate error messages.

Returns

string

Single string, that contains all error messages separated by the specified separator.