Class ValidationResult
Encapsulates the result of a mutation validation, including errors, warnings, and informational messages.
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Results
Assembly: ModularityKit.Mutator.dll
Syntax
public sealed class ValidationResult
Remarks
A ValidationResult collects detailed validation feedback during mutation processing. It distinguishes between three severity levels:
- Errors - critical issues that prevent mutation execution.
- Warnings - non-blocking issues that may indicate potential problems.
- Info - informational messages about validation context or suggestions.
The IsValid property returns true only when no errors are present.
Static factory methods (Success(), WithError(string, string, string?), WithErrors(params ValidationError[]))
provide convenient creation patterns.
Properties
| Edit this page View SourceErrors
List of validation errors that prevent mutation execution.
Declaration
public IReadOnlyList<ValidationError> Errors { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationError> |
Info
List of informational validation messages.
Declaration
public IReadOnlyList<ValidationInfo> Info { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationInfo> |
IsValid
Indicates whether the validation passed (no errors).
Declaration
public bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Warnings
List of validation warnings (non-blocking issues).
Declaration
public IReadOnlyList<ValidationWarning> Warnings { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationWarning> |
Methods
| Edit this page View SourceAddError(ValidationError)
Adds a ValidationError instance directly.
Declaration
public void AddError(ValidationError error)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationError | error | The validation error to add. |
AddError(string, string, string?)
Adds validation error with the specified path, message, and optional code.
Declaration
public void AddError(string path, string message, string? code = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the invalid property or field. |
| string | message | Description of the validation error. |
| string | code | Optional error code for categorization or localization. |
AddInfo(ValidationInfo)
Adds a ValidationInfo instance directly.
Declaration
public void AddInfo(ValidationInfo info)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationInfo | info | The informational message to add. |
AddInfo(string, string)
Adds an informational validation message.
Declaration
public void AddInfo(string path, string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the property or concept for this informational message. |
| string | message | The informational message. |
AddWarning(ValidationWarning)
Adds a ValidationWarning instance directly.
Declaration
public void AddWarning(ValidationWarning warning)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationWarning | warning | The validation warning to add. |
AddWarning(string, string, string?)
Adds validation warning with the specified path, message, and optional code.
Declaration
public void AddWarning(string path, string message, string? code = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the property or field causing the warning. |
| string | message | Description of the warning. |
| string | code | Optional code for categorization or localization. |
Success()
Returns a successful (empty) validation result.
Declaration
public static ValidationResult Success()
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult with no errors, warnings, or info. |
WithError(string, string, string?)
Creates a validation result with a single error.
Declaration
public static ValidationResult WithError(string path, string message, string? code = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the invalid property or field. |
| string | message | Description of the error. |
| string | code | Optional error code for categorization or localization. |
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult with the specified error. |
WithErrors(params ValidationError[])
Creates a validation result with multiple errors.
Declaration
public static ValidationResult WithErrors(params ValidationError[] errors)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationError[] | errors | The validation errors to include. |
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult with the specified errors. |