photo validators fixed

This commit is contained in:
2024-09-25 22:24:15 +02:00
Unverified
parent 9e9e5e1742
commit d02207a335
3 changed files with 28 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
using FluentValidation;
using WatchIt.Common.Model.Photos;
namespace WatchIt.WebAPI.Validators.Photos;
public class PhotoBackgroundDataRequestValidator : AbstractValidator<PhotoBackgroundDataRequest>
{
public PhotoBackgroundDataRequestValidator()
{
RuleFor(x => x).SetValidator(new PhotoBackgroundDataValidator());
}
}

View File

@@ -0,0 +1,13 @@
using FluentValidation;
using WatchIt.Common.Model.Photos;
namespace WatchIt.WebAPI.Validators.Photos;
public class PhotoBackgroundDataValidator : AbstractValidator<PhotoBackgroundData>
{
public PhotoBackgroundDataValidator()
{
RuleFor(x => x.FirstGradientColor).Must(x => x.Length == 3).WithMessage("First gradient color has to be 3 byte long");
RuleFor(x => x.SecondGradientColor).Must(x => x.Length == 3).WithMessage("Second gradient color has to be 3 byte long");
}
}