| | | 1 | | namespace RoleRadar.Domain.Tracking; |
| | | 2 | | |
| | | 3 | | public sealed record PostingSignal |
| | | 4 | | { |
| | | 5 | | public const int MaxEvidenceLength = 500; |
| | | 6 | | |
| | 336 | 7 | | public Guid Id { get; init; } |
| | 336 | 8 | | public string OwnerId { get; init; } |
| | 468 | 9 | | public Guid PostingId { get; init; } |
| | 492 | 10 | | public SignalType SignalType { get; init; } |
| | 358 | 11 | | public string Evidence { get; init; } |
| | 340 | 12 | | public DateTimeOffset ObservedAt { get; init; } |
| | 414 | 13 | | public string? DeadlineDate { get; init; } |
| | | 14 | | |
| | 256 | 15 | | public PostingSignal( |
| | 256 | 16 | | Guid id, |
| | 256 | 17 | | string ownerId, |
| | 256 | 18 | | Guid postingId, |
| | 256 | 19 | | SignalType signalType, |
| | 256 | 20 | | string evidence, |
| | 256 | 21 | | DateTimeOffset observedAt, |
| | 256 | 22 | | string? deadlineDate = null) |
| | | 23 | | { |
| | 256 | 24 | | if (id == Guid.Empty) |
| | | 25 | | { |
| | 2 | 26 | | throw new ArgumentException("Signal identifier cannot be empty.", nameof(id)); |
| | | 27 | | } |
| | | 28 | | |
| | 254 | 29 | | if (string.IsNullOrWhiteSpace(ownerId)) |
| | | 30 | | { |
| | 4 | 31 | | throw new ArgumentException("Owner identifier cannot be null or whitespace.", nameof(ownerId)); |
| | | 32 | | } |
| | | 33 | | |
| | 250 | 34 | | if (postingId == Guid.Empty) |
| | | 35 | | { |
| | 2 | 36 | | throw new ArgumentException("Posting identifier cannot be empty.", nameof(postingId)); |
| | | 37 | | } |
| | | 38 | | |
| | 248 | 39 | | if (string.IsNullOrWhiteSpace(evidence)) |
| | | 40 | | { |
| | 4 | 41 | | throw new ArgumentException("Evidence cannot be null or whitespace.", nameof(evidence)); |
| | | 42 | | } |
| | | 43 | | |
| | 244 | 44 | | if (evidence.Length > MaxEvidenceLength) |
| | | 45 | | { |
| | 2 | 46 | | throw new ArgumentException($"Evidence cannot exceed {MaxEvidenceLength} characters.", nameof(evidence)); |
| | | 47 | | } |
| | | 48 | | |
| | 242 | 49 | | if (!string.IsNullOrWhiteSpace(deadlineDate)) |
| | | 50 | | { |
| | 60 | 51 | | if (!DateOnly.TryParseExact(deadlineDate.Trim(), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCul |
| | | 52 | | { |
| | 2 | 53 | | throw new ArgumentException("Deadline date must be in YYYY-MM-DD format.", nameof(deadlineDate)); |
| | | 54 | | } |
| | | 55 | | } |
| | | 56 | | |
| | 240 | 57 | | Id = id; |
| | 240 | 58 | | OwnerId = ownerId.Trim(); |
| | 240 | 59 | | PostingId = postingId; |
| | 240 | 60 | | SignalType = signalType; |
| | 240 | 61 | | Evidence = evidence.Trim(); |
| | 240 | 62 | | ObservedAt = observedAt; |
| | 240 | 63 | | DeadlineDate = string.IsNullOrWhiteSpace(deadlineDate) ? null : deadlineDate.Trim(); |
| | 240 | 64 | | } |
| | | 65 | | } |