Files
meezi/src/Meezi.API/Validators/PatchCafeSettingsRequestValidator.cs
T

34 lines
1.7 KiB
C#
Raw Normal View History

2026-05-27 21:33:48 +03:30
using FluentValidation;
using Meezi.API.Models.Cafes;
using Meezi.Core.Utilities;
2026-05-27 21:33:48 +03:30
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.Slug)
.Must(s => s == null || SlugHelper.IsValidSlug(s))
.WithMessage("Slug must be 2-80 lowercase letters, digits, or hyphens (e.g. my-cafe).")
.When(x => x.Slug is not null);
2026-05-27 21:33:48 +03:30
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);
});
}
}