Reformat RuleBuilder in ChangeColorValidator
This commit is contained in:
@@ -16,34 +16,29 @@ public sealed class ChangeColorsRequestValidator
|
|||||||
{
|
{
|
||||||
public 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")
|
||||||
RuleFor(x => x.BannerTop)
|
.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")
|
.When(x => x.BannerTop is not null);
|
||||||
.Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #");
|
|
||||||
});
|
RuleFor(x => x.BannerBottom)
|
||||||
When(x => x.BannerBottom 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.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")
|
.When(x => x.BannerBottom is not null);
|
||||||
.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.Accent)
|
||||||
});
|
.MinimumLength(4).WithMessage("The minimum value should be in the format #444")
|
||||||
When(x => x.Accent is not null, () =>
|
.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.Accent)
|
.When(x => x.Accent 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.Menu)
|
||||||
.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.Menu is not null, () =>
|
.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 #");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +52,9 @@ public class ChangeColorsHandler(
|
|||||||
Options(o => o.WithTags("Creators"));
|
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
|
var creator = await context
|
||||||
.Creators
|
.Creators
|
||||||
|
|||||||
Reference in New Issue
Block a user