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
resultResultThe result to complete.
errorMessagestringThe 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
resultResultThe result to complete.
errorMessagestringThe message describing the validation failure.
severitySeverityThe 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
resultResultThe result to complete.
errorMessagestringThe message describing the validation failure.
codestringThe 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
resultResultThe result to complete.
errorMessagestringThe message describing the validation failure.
codestringThe code identifying the validation rule that failed.
severitySeverityThe 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
resultResult<TResult>The result to complete.
errorMessagestringThe message describing the validation failure.
Returns
- Result<TResult>
The result, now failed.
Type Parameters
TResultThe 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
resultResult<TResult>The result to complete.
errorMessagestringThe message describing the validation failure.
severitySeverityThe severity of the validation error.
Returns
- Result<TResult>
The result, now failed.
Type Parameters
TResultThe 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
resultResult<TResult>The result to complete.
errorMessagestringThe message describing the validation failure.
codestringThe code identifying the validation rule that failed.
Returns
- Result<TResult>
The result, now failed.
Type Parameters
TResultThe 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
resultResult<TResult>The result to complete.
errorMessagestringThe message describing the validation failure.
codestringThe code identifying the validation rule that failed.
severitySeverityThe severity of the validation error.
Returns
- Result<TResult>
The result, now failed.
Type Parameters
TResultThe type of the value carried by the result.