namespace DocumentOperator.Domain.Models.ValueObjects;

public sealed class TenantId
{
    public string Value { get; }

    private TenantId(string value)
    {
        Value = value;
    }

    public static TenantId Create(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new Common.Exceptions.DomainValidationException("TenantId cannot be empty.");

        if (value.Length > 100)
            throw new Common.Exceptions.DomainValidationException("TenantId cannot exceed 100 characters.");

        // Normalisierung: Lowercase
        var normalized = value.Trim().ToLowerInvariant();

        return new TenantId(normalized);
    }

    public override string ToString() => Value;

    // Equality
    public override bool Equals(object? obj)
    {
        if (obj is not TenantId other)
            return false;

        return Value == other.Value;
    }

    public override int GetHashCode()
    {
        return Value.GetHashCode();
    }
}