Table of Contents

Class ValidationExtensions

Namespace
Arc4u.Results.Validation
Assembly
Arc4u.Results.dll

Extension methods adding a ValidationError to a FluentResults.Result or a FluentResults.Result<TValue>.

public static class ValidationExtensions
Inheritance
ValidationExtensions
Inherited Members

Examples

Result<int> result = Result.Ok(0)
    .WithValidationError("The quantity must be positive.", "QTY_POSITIVE", Severity.Error);

Methods

WithValidationError(Result, string)

Adds a validation error with the default severity (Error) to the result.

public static Result WithValidationError(this Result result, string errorMessage)

Parameters

result Result

The result to complete.

errorMessage string

The message describing the validation failure.

Returns

Result

The result, now failed.

WithValidationError(Result, string, Severity)

Adds a validation error with the given severity to the result.

public static Result WithValidationError(this Result result, string errorMessage, Severity severity)

Parameters

result Result

The result to complete.

errorMessage string

The message describing the validation failure.

severity Severity

The severity of the validation error.

Returns

Result

The result, now failed.

WithValidationError(Result, string, string)

Adds a validation error with the given code and the default severity to the result.

public static Result WithValidationError(this Result result, string errorMessage, string code)

Parameters

result Result

The result to complete.

errorMessage string

The message describing the validation failure.

code string

The code identifying the validation rule that failed.

Returns

Result

The result, now failed.

WithValidationError(Result, string, string, Severity)

Adds a validation error with the given code and severity to the result.

public static Result WithValidationError(this Result result, string errorMessage, string code, Severity severity)

Parameters

result Result

The result to complete.

errorMessage string

The message describing the validation failure.

code string

The code identifying the validation rule that failed.

severity Severity

The severity of the validation error.

Returns

Result

The result, now failed.

WithValidationError<TResult>(Result<TResult>, string)

Adds a validation error with the default severity (Error) to the result.

public static Result<TResult> WithValidationError<TResult>(this Result<TResult> result, string errorMessage)

Parameters

result Result<TResult>

The result to complete.

errorMessage string

The message describing the validation failure.

Returns

Result<TResult>

The result, now failed.

Type Parameters

TResult

The type of the value carried by the result.

WithValidationError<TResult>(Result<TResult>, string, Severity)

Adds a validation error with the given severity to the result.

public static Result<TResult> WithValidationError<TResult>(this Result<TResult> result, string errorMessage, Severity severity)

Parameters

result Result<TResult>

The result to complete.

errorMessage string

The message describing the validation failure.

severity Severity

The severity of the validation error.

Returns

Result<TResult>

The result, now failed.

Type Parameters

TResult

The type of the value carried by the result.

WithValidationError<TResult>(Result<TResult>, string, string)

Adds a validation error with the given code and the default severity to the result.

public static Result<TResult> WithValidationError<TResult>(this Result<TResult> result, string errorMessage, string code)

Parameters

result Result<TResult>

The result to complete.

errorMessage string

The message describing the validation failure.

code string

The code identifying the validation rule that failed.

Returns

Result<TResult>

The result, now failed.

Type Parameters

TResult

The type of the value carried by the result.

WithValidationError<TResult>(Result<TResult>, string, string, Severity)

Adds a validation error with the given code and severity to the result.

public static Result<TResult> WithValidationError<TResult>(this Result<TResult> result, string errorMessage, string code, Severity severity)

Parameters

result Result<TResult>

The result to complete.

errorMessage string

The message describing the validation failure.

code string

The code identifying the validation rule that failed.

severity Severity

The severity of the validation error.

Returns

Result<TResult>

The result, now failed.

Type Parameters

TResult

The type of the value carried by the result.