using System;

namespace StellaOps.Policy;

/// <summary>
/// Represents a validation or normalization issue discovered while processing a policy document.
/// </summary>
public sealed record PolicyIssue(string Code, string Message, PolicyIssueSeverity Severity, string Path)
{
    public static PolicyIssue Error(string code, string message, string path)
        => new(code, message, PolicyIssueSeverity.Error, path);

    public static PolicyIssue Warning(string code, string message, string path)
        => new(code, message, PolicyIssueSeverity.Warning, path);

    public static PolicyIssue Info(string code, string message, string path)
        => new(code, message, PolicyIssueSeverity.Info, path);

    public PolicyIssue EnsurePath(string fallbackPath)
        => string.IsNullOrWhiteSpace(Path) ? this with { Path = fallbackPath } : this;
}

public enum PolicyIssueSeverity
{
    Error,
    Warning,
    Info,
}
