using ColaFlow.Shared.Kernel.Common;

namespace ColaFlow.Modules.Identity.Domain.Aggregates.Users;

public sealed class FullName : ValueObject
{
    public string Value { get; }

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

    public static FullName Create(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("Full name cannot be empty", nameof(value));

        if (value.Length < 2)
            throw new ArgumentException("Full name must be at least 2 characters", nameof(value));

        if (value.Length > 100)
            throw new ArgumentException("Full name cannot exceed 100 characters", nameof(value));

        return new FullName(value.Trim());
    }

    protected override IEnumerable<object> GetAtomicValues()
    {
        yield return Value;
    }

    public override string ToString() => Value;

    // Implicit conversion
    public static implicit operator string(FullName name) => name.Value;
}
