using Domain.Entities.EmailVerification.ValueObject; namespace Domain.Entities.EmailVerification { public class EmailVerifyNumber { public int ID { get; private set; } public VerificationType Type { get; private set; } public string Email { get; private set; } = default!; public string Code { get; private set; } = default!; public bool IsVerified { get; private set; } = false; public DateTime Expiration { get; private set; } public DateTime CreatedAt { get; private set; } = DateTime.UtcNow; private EmailVerifyNumber() { } private EmailVerifyNumber(VerificationType type, string email, string code, DateTime expiration) { if (string.IsNullOrWhiteSpace(email)) { throw new ArgumentException("Email is required.", nameof(email)); } if (email.Length > 60) { throw new ArgumentOutOfRangeException(nameof(email)); } if (string.IsNullOrWhiteSpace(code)) { throw new ArgumentException("Code is required.", nameof(code)); } if (code.Length > 10) { throw new ArgumentOutOfRangeException(nameof(code)); } Type = type; Email = email; Code = code; Expiration = expiration; CreatedAt = DateTime.UtcNow; } public static EmailVerifyNumber Create(VerificationType type, string email, string code, DateTime expiration) { return new(type, email, code, expiration); } public void MarkVerified() { IsVerified = true; } } }