namespace Nalu.Web.PostProcessors;

public record ProcessorResult
{
    public string? Value { get; init; }
    public bool IsValid { get; init; } = true;
    public bool WasCorrected { get; init; }
    public string? OriginalValue { get; init; }
    public string? InvalidReason { get; init; }

    /// Overrides the suggestion template key selected by SuggestionBuilder (e.g. "when_minor").
    public string? SuggestionKeyOverride { get; init; }

    public static ProcessorResult Ok(string? value) => new() { Value = value };
    public static ProcessorResult Invalid(string? reason = null) => new() { IsValid = false, InvalidReason = reason };
    public static ProcessorResult Corrected(string value, string original) =>
        new() { Value = value, WasCorrected = true, OriginalValue = original };
    public static ProcessorResult WithOverride(string value, string suggestionKey) =>
        new() { Value = value, SuggestionKeyOverride = suggestionKey };
}

public interface IPostProcessor
{
    string Name { get; }
    ProcessorResult Process(string? value);
}
