Class ValidationResult
Represents the result of validating a mutation or state change. Contains errors, warnings, and informational messages produced during validation.
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Results
Assembly: ModularityKit.Mutator.dll
Syntax
public sealed class ValidationResult
Properties
| Edit this page View SourceErrors
Read-only list of validation errors. Each error indicates a violation of rules that prevents the mutation from being applied.
Declaration
public IReadOnlyList<ValidationError> Errors { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationError> |
Info
Read-only list of informational messages produced during validation.
Declaration
public IReadOnlyList<ValidationInfo> Info { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationInfo> |
IsValid
Indicates whether the validation passed successfully. True if there are no errors; false otherwise.
Declaration
public bool IsValid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Warnings
Read-only list of validation warnings. Warnings indicate potential issues that do not block mutation execution.
Declaration
public IReadOnlyList<ValidationWarning> Warnings { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ValidationWarning> |
Methods
| Edit this page View SourceAddError(ValidationError)
Adds an existing ValidationError instance.
Declaration
public void AddError(ValidationError error)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationError | error | The error to add. |
AddError(string, string, string?)
Adds a new validation error.
Declaration
public void AddError(string path, string message, string? code = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path or property associated with the error. |
| string | message | Human-readable description of the error. |
| string | code | Optional error code for categorization. |
AddInfo(ValidationInfo)
Adds an existing ValidationInfo instance.
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 | The path or property associated with the info. |
| string | message | Human-readable informational message. |
AddWarning(ValidationWarning)
Adds an existing ValidationWarning instance.
Declaration
public void AddWarning(ValidationWarning warning)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationWarning | warning | The warning to add. |
AddWarning(string, string, string?)
Adds a new validation warning.
Declaration
public void AddWarning(string path, string message, string? code = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path or property associated with the warning. |
| string | message | Human-readable description of the warning. |
| string | code | Optional warning code for categorization. |
Success()
Creates a successful validation result with no errors.
Declaration
public static ValidationResult Success()
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult indicating success. |
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 | The path or property associated with the error. |
| string | message | Human-readable description of the error. |
| string | code | Optional error code. |
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult containing one error. |
WithErrors(params ValidationError[])
Creates a validation result containing multiple errors.
Declaration
public static ValidationResult WithErrors(params ValidationError[] errors)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationError[] | errors | Array of ValidationError to include. |
Returns
| Type | Description |
|---|---|
| ValidationResult | A ValidationResult containing the specified errors. |