namespace HrynCo.NotificationService.Worker.Services.Push; using HrynCo.NotificationService.Contracts.Messages; public static class PushMessageValidator { public static bool IsValid(SendPushMessage? message) { if (message?.Data is not { } data || message.CorrelationContext is null) return false; return Guid.TryParse(message.CorrelationContext.CorrelationId, out _) && data.Version == 1 && data.RegistrationId != Guid.Empty && data.BindingId != Guid.Empty && data.ServiceName is { Length: > 0 and <= 100 } && data.UserId != Guid.Empty && data.Token is { Length: > 0 and <= 2048 } && data.TokenHash is { Length: 64 } && data.Title is { Length: > 0 and <= 100 } && data.Body is { Length: > 0 and <= 500 } && data.Route == "/home" && data.ExpiresAt <= DateTimeOffset.UtcNow.AddMinutes(15); } }