using ZB.MOM.WW.Configuration;

namespace ZB.MOM.WW.ScadaBridge.AuditLog.Central;

/// <summary>
/// Validates <see cref="SiteAuditReconciliationOptions"/> at host startup
/// (arch-review 08 round 2 NF4). A zero tick interval spins the reconciliation
/// singleton, a zero batch pulls nothing per RPC, and a zero stalled-cycle
/// threshold would fire the stalled signal on the first non-draining cycle.
/// <see cref="SiteAuditReconciliationOptions.ReconciliationIntervalOverride"/>
/// is test-only (per the class remarks) and is deliberately not validated.
/// </summary>
public sealed class SiteAuditReconciliationOptionsValidator
    : OptionsValidatorBase<SiteAuditReconciliationOptions>
{
    /// <inheritdoc />
    protected override void Validate(ValidationBuilder builder, SiteAuditReconciliationOptions options)
    {
        builder.RequireThat(options.ReconciliationIntervalSeconds > 0,
            $"AuditLog:Reconciliation:{nameof(SiteAuditReconciliationOptions.ReconciliationIntervalSeconds)} " +
            $"({options.ReconciliationIntervalSeconds}) must be > 0.");

        builder.RequireThat(options.BatchSize > 0,
            $"AuditLog:Reconciliation:{nameof(SiteAuditReconciliationOptions.BatchSize)} " +
            $"({options.BatchSize}) must be > 0.");

        builder.RequireThat(options.StalledAfterNonDrainingCycles > 0,
            $"AuditLog:Reconciliation:{nameof(SiteAuditReconciliationOptions.StalledAfterNonDrainingCycles)} " +
            $"({options.StalledAfterNonDrainingCycles}) must be > 0.");
    }
}
