Add validator tests for brewery and user commands (#282)

This commit is contained in:
Aaron Po
2026-09-06 17:48:03 -04:00
committed by GitHub
parent 9d5a463d93
commit a3ec7d63f2
13 changed files with 977 additions and 3 deletions

View File

@@ -25,18 +25,23 @@ public class CreateBreweryValidator : AbstractValidator<CreateBreweryCommand>
RuleFor(x => x.Location).NotNull().WithMessage("Location is required.");
RuleFor(x => x.Location.CityId).NotEmpty().WithMessage("CityId is required.");
RuleFor(x => x.Location.CityId)
.NotEmpty()
.WithMessage("CityId is required.")
.When(x => x.Location != null);
RuleFor(x => x.Location.AddressLine1)
.NotEmpty()
.WithMessage("Address line 1 is required.")
.MaximumLength(256)
.WithMessage("Address line 1 cannot exceed 256 characters.");
.WithMessage("Address line 1 cannot exceed 256 characters.")
.When(x => x.Location != null);
RuleFor(x => x.Location.PostalCode)
.NotEmpty()
.WithMessage("Postal code is required.")
.MaximumLength(20)
.WithMessage("Postal code cannot exceed 20 characters.");
.WithMessage("Postal code cannot exceed 20 characters.")
.When(x => x.Location != null);
}
}