2024-07-03 22:18:32 +02:00
|
|
|
|
using FluentValidation;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
|
|
|
|
|
|
using WatchIt.Common.Model.Media;
|
|
|
|
|
|
using WatchIt.Database;
|
2024-09-25 22:24:15 +02:00
|
|
|
|
using WatchIt.WebAPI.Validators.Photos;
|
2024-07-03 22:18:32 +02:00
|
|
|
|
|
|
|
|
|
|
namespace WatchIt.WebAPI.Validators.Media;
|
|
|
|
|
|
|
|
|
|
|
|
public class MediaPhotoRequestValidator : AbstractValidator<MediaPhotoRequest>
|
|
|
|
|
|
{
|
2024-09-25 22:24:15 +02:00
|
|
|
|
public MediaPhotoRequestValidator()
|
2024-07-03 22:18:32 +02:00
|
|
|
|
{
|
|
|
|
|
|
RuleFor(x => x.Image).NotEmpty();
|
|
|
|
|
|
RuleFor(x => x.MimeType).Matches(@"\w+/.+").WithMessage("Incorrect mimetype");
|
|
|
|
|
|
When(x => x.Background is not null, () =>
|
|
|
|
|
|
{
|
2024-09-25 22:24:15 +02:00
|
|
|
|
RuleFor(x => x.Background!).SetValidator(new PhotoBackgroundDataValidator());
|
2024-07-03 22:18:32 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|