Files
Yaojia Wang 014d62bcc2 Project Init
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 23:55:18 +01:00

39 lines
1.1 KiB
C#

using ColaFlow.Shared.Kernel.Common;
using ColaFlow.Modules.ProjectManagement.Domain.Exceptions;
namespace ColaFlow.Modules.ProjectManagement.Domain.ValueObjects;
/// <summary>
/// ProjectKey Value Object (e.g., "COLA", "FLOW")
/// </summary>
public sealed class ProjectKey : ValueObject
{
public string Value { get; private set; }
private ProjectKey(string value)
{
Value = value;
}
public static ProjectKey Create(string value)
{
if (string.IsNullOrWhiteSpace(value))
throw new DomainException("Project key cannot be empty");
if (value.Length > 10)
throw new DomainException("Project key cannot exceed 10 characters");
if (!System.Text.RegularExpressions.Regex.IsMatch(value, "^[A-Z0-9]+$"))
throw new DomainException("Project key must contain only uppercase letters and numbers");
return new ProjectKey(value);
}
protected override IEnumerable<object> GetAtomicValues()
{
yield return Value;
}
public override string ToString() => Value;
}