Last active
April 18, 2020 05:55
-
-
Save DavidRogersDev/0cf529eaabf54007591ca59eac638a4a to your computer and use it in GitHub Desktop.
Gist for Medium Article - ColorCollectionValidator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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