namespace Monitoring.Core.Domain.AssetManagement;

public sealed class AssetName
{
	private AssetName(string value)
	{
		Value = value;
	}

	public string Value { get; }
	public const int MaxLength = 100;
	public const int MinLength = 3;

	public static AssetName Create(string value)
	{
		if (string.IsNullOrEmpty(value))
		{
			throw new ArgumentException("Значение не может быть пустым.", nameof(value));
		}

		if (value.Length is < MinLength or > MaxLength)
		{
			throw new ArgumentException($"Значение должно быть длинной от {MinLength} до {MaxLength} символов.", nameof(value));
		}

		return new AssetName(value);
	}

	public static implicit operator string(AssetName assetName)
	{
		return assetName.Value;
	}
}
