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

@@ -15,26 +15,35 @@ public sealed class ChangeColorsRequestValidator
: Validator<ChangeColorsRequest>
{
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 #");
});
}
}