Merged PR 105: Fixed color validator ( they are selected one by one in the UI )

Fixed color validator ( they are selected one by one in the UI )
This commit is contained in:
Dominic Villemure
2024-08-18 16:04:27 +00:00

View File

@@ -16,25 +16,34 @@ public sealed class ChangeColorsRequestValidator
{ {
public ChangeColorsRequestValidator() public ChangeColorsRequestValidator()
{ {
RuleFor(x => x.BannerTop) When(x => x.BannerTop is not null, () =>
.MinimumLength(4).WithMessage("The minimum value should be in the format #444") {
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") RuleFor(x => x.BannerTop)
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); .MinimumLength(4).WithMessage("The minimum value should be in the format #444")
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
RuleFor(x => x.BannerBottom) .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
.MinimumLength(4).WithMessage("The minimum value should be in the format #444") });
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") When(x => x.BannerBottom is not null, () =>
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); {
RuleFor(x => x.BannerBottom)
RuleFor(x => x.Accent) .MinimumLength(4).WithMessage("The minimum value should be in the format #444")
.MinimumLength(4).WithMessage("The minimum value should be in the format #444") .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344")
.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 #");
.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") RuleFor(x => x.Accent)
.MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") .MinimumLength(4).WithMessage("The minimum value should be in the format #444")
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); .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 #");
});
} }
} }