Skip to content

Instantly share code, notes, and snippets.

@DavidRogersDev
Last active April 18, 2020 05:55
Show Gist options
  • Save DavidRogersDev/0cf529eaabf54007591ca59eac638a4a to your computer and use it in GitHub Desktop.
Save DavidRogersDev/0cf529eaabf54007591ca59eac638a4a to your computer and use it in GitHub Desktop.
Gist for Medium Article - ColorCollectionValidator
public class ColorCollectionValidator : AbstractValidator<IEnumerable<ColorPayloadDto>>
{
public ColorCollectionValidator()
{
// This is a bit of a silly validator.
// Normally a collection would be a property on a DTO.
// But it interesting to see that you can do this with FluentValidation at all.
RuleFor(c => c)
.Must(c => c.Any())
.WithMessage("The color collection must contain at least one colour.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment