diff --git a/src/Web/Features/Contents/Handlers/ChangeColors.cs b/src/Web/Features/Contents/Handlers/ChangeColors.cs index 25e80f3..db88aa3 100644 --- a/src/Web/Features/Contents/Handlers/ChangeColors.cs +++ b/src/Web/Features/Contents/Handlers/ChangeColors.cs @@ -16,34 +16,29 @@ public sealed class ChangeColorsRequestValidator { public ChangeColorsRequestValidator() { - When(x => x.BannerTop is not null, () => - { - RuleFor(x => x.BannerTop) - .MinimumLength(4).WithMessage("The minimum value should be in the format #444") - .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - }); - When(x => x.BannerBottom is not null, () => - { - RuleFor(x => x.BannerBottom) - .MinimumLength(4).WithMessage("The minimum value should be in the format #444") - .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - }); - When(x => x.Accent is not null, () => - { - RuleFor(x => x.Accent) - .MinimumLength(4).WithMessage("The minimum value should be in the format #444") - .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - }); - When(x => x.Menu is not null, () => - { - RuleFor(x => x.Menu) - .MinimumLength(4).WithMessage("The minimum value should be in the format #444") - .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - }); + RuleFor(x => x.BannerTop) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") + .When(x => x.BannerTop is not null); + + RuleFor(x => x.BannerBottom) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") + .When(x => x.BannerBottom is not null); + + RuleFor(x => x.Accent) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") + .When(x => x.Accent is not null); + + RuleFor(x => x.Menu) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") + .When(x => x.Menu is not null); } } @@ -57,7 +52,9 @@ public class ChangeColorsHandler( Options(o => o.WithTags("Creators")); } - public override async Task HandleAsync(ChangeColorsRequest request, CancellationToken ct) + public override async Task HandleAsync( + ChangeColorsRequest request, + CancellationToken ct) { var creator = await context .Creators