Files
minattest/backend/src/MinAttest.Application/Features/Attests/Commands/PersonUploadAttestCommandValidator.cs
T
Stein Helge Riise ede31fbb7e Initial import
2025-11-17 08:32:46 +01:00

23 lines
926 B
C#

using FluentValidation;
namespace MinAttest.Application.Features.Attests.Commands;
public class PersonUploadAttestCommandValidator : AbstractValidator<PersonUploadAttestCommand>
{
public PersonUploadAttestCommandValidator()
{
RuleFor(x => x.PersonId).NotEqual(Guid.Empty);
RuleFor(x => x.Request.Title).NotEmpty().MaximumLength(200);
RuleFor(x => x.Request.BlobPath).MaximumLength(500);
RuleFor(x => x.Request.From).LessThanOrEqualTo(x => x.Request.To);
RuleFor(x => x.Request)
.Must(r => !string.IsNullOrWhiteSpace(r.BlobPath) || !string.IsNullOrWhiteSpace(r.ContentBase64))
.WithMessage("Either BlobPath or ContentBase64 must be provided");
When(x => !string.IsNullOrWhiteSpace(x.Request.ContentBase64), () =>
{
RuleFor(x => x.Request.ContentType).NotEmpty().MaximumLength(255);
});
}
}