namespace KArtSell.Modules.ModelOperations.Domain;

public sealed record MetricDefinitionVersion(
    string MetricCode,
    int DefinitionVersion,
    string CohortDefinitionHash,
    string WindowDefinition,
    string AggregationMethod,
    string ThresholdContractHash,
    DateTimeOffset EffectiveFrom)
{
    public void EnsureValid()
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(MetricCode);
        if (DefinitionVersion <= 0) throw new InvalidOperationException("Metric definition version must be positive.");
        ArgumentException.ThrowIfNullOrWhiteSpace(CohortDefinitionHash);
        ArgumentException.ThrowIfNullOrWhiteSpace(WindowDefinition);
        ArgumentException.ThrowIfNullOrWhiteSpace(AggregationMethod);
        ArgumentException.ThrowIfNullOrWhiteSpace(ThresholdContractHash);
    }
}
