.NET 10 solution for Ping, a Discord style chat app: Domain, Application and Infrastructure projects plus the Api host. SignalR for chat and presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible storage for attachments, and OIDC auth shared with the Musify Zitadel instance. Includes the Compose stack for local development.
18 lines
524 B
C#
18 lines
524 B
C#
using FluentValidation;
|
|
using Ping.Api.DataTransferObjects.Messages;
|
|
|
|
namespace Ping.Api.Validators.Messages;
|
|
|
|
public sealed class SendMessageRequestValidator : AbstractValidator<SendMessageRequest>
|
|
{
|
|
public SendMessageRequestValidator()
|
|
{
|
|
RuleFor(x => x.Content)
|
|
.MaximumLength(4000);
|
|
|
|
RuleFor(x => x)
|
|
.Must(x => !string.IsNullOrWhiteSpace(x.Content) || (x.Attachments?.Count ?? 0) > 0)
|
|
.WithMessage("A message needs content or at least one attachment");
|
|
}
|
|
}
|