using ZB.MOM.WW.Configuration;

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

/// <summary>
/// Validates <see cref="AuditLogPartitionMaintenanceOptions"/> at host startup
/// (arch-review 08 round 2 NF4). A zero tick interval spins the maintenance
/// hosted service; a zero look-ahead leaves <c>pf_AuditLog_Month</c> without a
/// future monthly boundary, risking inserts into the unbounded tail partition.
/// </summary>
public sealed class AuditLogPartitionMaintenanceOptionsValidator
    : OptionsValidatorBase<AuditLogPartitionMaintenanceOptions>
{
    /// <inheritdoc />
    protected override void Validate(ValidationBuilder builder, AuditLogPartitionMaintenanceOptions options)
    {
        builder.RequireThat(options.IntervalSeconds > 0,
            $"AuditLog:PartitionMaintenance:{nameof(AuditLogPartitionMaintenanceOptions.IntervalSeconds)} " +
            $"({options.IntervalSeconds}) must be > 0.");

        builder.RequireThat(options.LookaheadMonths > 0,
            $"AuditLog:PartitionMaintenance:{nameof(AuditLogPartitionMaintenanceOptions.LookaheadMonths)} " +
            $"({options.LookaheadMonths}) must be > 0.");
    }
}
