23 lines
926 B
C#
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);
|
|
});
|
|
}
|
|
}
|
|
|