Output some kind of identity for failing objects
See original GitHub issueWe have the following validation of an input:
public class UserRegisterValidator : AbstractValidator<UserRegister>
{
public UserRegisterValidator()
{
RuleFor(s => s.Users).SetCollectionValidator(new UserValidator());
}
}
public class UserValidator : AbstractValidator<User>
{
public UserValidator ()
{
RuleFor(s => s.Email).NotEmpty()
}
}
This will present the user with messages like
‘Email’ should not be empty.
But who’s email should not be empty?
I’ve seen others getting messages like
'Users[0].Email should not be empty
How can I enable such messages?
But I would like to go one step further. I would like to specify some kind of id for the object, recognizable for the user, like
‘User[John Smith].Email’ should not be empty.
How is that possible?
I guess the answer lies in the PropertyNameResolver
, but I’m not sure how…
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Kinematic Equations and Free Fall
Like any moving object, the motion of an object in free fall can be described by four ... The second step involves the...
Read more >2.7: Falling Objects
Falling objects form an interesting class of motion problems. ... Figure 2.7.1: A hammer and a feather will fall with the same constant ......
Read more >Dropped Object Prevention: The Definitive Guide
This is the ultimate guide to stopping dropped objects when working at height. First, we'll learn how tools at height present a constant ......
Read more >How to Implement a Dropped Objects Prevention Plan
First, an “aha!” moment occurs, a sudden bolt of recognition when a site safety manager, supervisor or someone else recognizes dropped objects ...
Read more >Falling Objects Detection for Near Miss Incidents ...
This paper proposes a deep learning-based video monitoring method to automatically detect and analyze the probable causes of the near miss incident (falling...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another idea I had, was to create a new
WithMessage( )
that get the default message as input:Allowing for ‘light’ customization of the defaults.
Correct, but because it’s separate there’s probably scope for extending it to support this in a similar way to how WithMessage allows custom format options to be applied via the overload of WithMessage that takes an array of lambda expressions.