TaskValidator.Core.ValidationResult (TaskValidator v0.9.5)

View Source

Represents the result of a validation operation.

This struct aggregates validation errors and warnings, providing a consistent interface for handling validation outcomes throughout the system.

Summary

Functions

Adds an error to the validation result.

Adds multiple errors to the validation result.

Adds a warning to the validation result.

Adds multiple warnings to the validation result.

Combines multiple validation results into a single result.

Gets the number of errors.

Gets errors for a specific task ID.

Creates a failed validation result.

Formats the validation result for display.

Groups errors by type for analysis.

Checks if a specific error type exists in the result.

Checks if the result has any issues (errors or warnings).

Gets the total number of issues (errors + warnings).

Creates a validation result with both errors and warnings.

Creates a successful validation result.

Gets the number of warnings.

Types

t()

@type t() :: %TaskValidator.Core.ValidationResult{
  errors: [TaskValidator.Core.ValidationError.t()],
  task_count: non_neg_integer(),
  valid?: boolean(),
  validated_at: DateTime.t(),
  warnings: [TaskValidator.Core.ValidationError.t()]
}

Functions

add_error(result, error)

@spec add_error(t(), TaskValidator.Core.ValidationError.t()) :: t()

Adds an error to the validation result.

add_errors(result, errors)

@spec add_errors(t(), [TaskValidator.Core.ValidationError.t()]) :: t()

Adds multiple errors to the validation result.

add_warning(result, warning)

@spec add_warning(t(), TaskValidator.Core.ValidationError.t()) :: t()

Adds a warning to the validation result.

add_warnings(result, warnings)

@spec add_warnings(t(), [TaskValidator.Core.ValidationError.t()]) :: t()

Adds multiple warnings to the validation result.

combine(results)

@spec combine([t()]) :: t()

Combines multiple validation results into a single result.

The combined result is valid only if all input results are valid. All errors and warnings are aggregated.

error_count(validation_result)

@spec error_count(t()) :: non_neg_integer()

Gets the number of errors.

errors_for_task(validation_result, task_id)

@spec errors_for_task(t(), String.t()) :: [TaskValidator.Core.ValidationError.t()]

Gets errors for a specific task ID.

failure(errors, opts \\ [])

Creates a failed validation result.

format(validation_result)

@spec format(t()) :: String.t()

Formats the validation result for display.

group_errors_by_type(validation_result)

@spec group_errors_by_type(t()) :: %{
  required(TaskValidator.Core.ValidationError.error_type()) => [
    TaskValidator.Core.ValidationError.t()
  ]
}

Groups errors by type for analysis.

has_error_type?(validation_result, error_type)

@spec has_error_type?(t(), TaskValidator.Core.ValidationError.error_type()) ::
  boolean()

Checks if a specific error type exists in the result.

has_issues?(result)

@spec has_issues?(t()) :: boolean()

Checks if the result has any issues (errors or warnings).

issue_count(validation_result)

@spec issue_count(t()) :: non_neg_integer()

Gets the total number of issues (errors + warnings).

new(errors, warnings, opts \\ [])

Creates a validation result with both errors and warnings.

success(opts \\ [])

@spec success(keyword()) :: t()

Creates a successful validation result.

warning_count(validation_result)

@spec warning_count(t()) :: non_neg_integer()

Gets the number of warnings.