29 lines
1.4 KiB
C#
29 lines
1.4 KiB
C#
|
|
using FluentValidation;
|
||
|
|
using Meezi.API.Models.Cafes;
|
||
|
|
|
||
|
|
namespace Meezi.API.Validators;
|
||
|
|
|
||
|
|
public class PatchCafeSettingsRequestValidator : AbstractValidator<PatchCafeSettingsRequest>
|
||
|
|
{
|
||
|
|
public PatchCafeSettingsRequestValidator()
|
||
|
|
{
|
||
|
|
RuleFor(x => x.Name).MaximumLength(200).When(x => x.Name is not null);
|
||
|
|
RuleFor(x => x.Phone).MaximumLength(20).When(x => x.Phone is not null);
|
||
|
|
RuleFor(x => x.Address).MaximumLength(500).When(x => x.Address is not null);
|
||
|
|
RuleFor(x => x.City).MaximumLength(100).When(x => x.City is not null);
|
||
|
|
RuleFor(x => x.Description).MaximumLength(2000).When(x => x.Description is not null);
|
||
|
|
RuleFor(x => x.LogoUrl).MaximumLength(500).When(x => x.LogoUrl is not null);
|
||
|
|
RuleFor(x => x.CoverImageUrl).MaximumLength(500).When(x => x.CoverImageUrl is not null);
|
||
|
|
RuleFor(x => x.SnappfoodVendorId).MaximumLength(100).When(x => x.SnappfoodVendorId is not null);
|
||
|
|
When(x => x.Theme is not null, () =>
|
||
|
|
{
|
||
|
|
RuleFor(x => x.Theme!.PaletteId).NotEmpty().MaximumLength(48);
|
||
|
|
RuleFor(x => x.Theme!.PanelStyle).NotEmpty().MaximumLength(24);
|
||
|
|
RuleFor(x => x.Theme!.MenuStyle).NotEmpty().MaximumLength(24);
|
||
|
|
RuleFor(x => x.Theme!.MenuTexture).NotEmpty().MaximumLength(24);
|
||
|
|
RuleFor(x => x.Theme!.Density).NotEmpty().MaximumLength(24);
|
||
|
|
RuleFor(x => x.Theme!.Radius).NotEmpty().MaximumLength(24);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|