valit-stack/Valit

Default error messages

GooRiOn opened this issue · 1 comments

I think it would be nice to have a default messages for all validation rules. Notice that in most cases you would write message like:

.Ensure(m => m.IntValue, _=>_
    .IsGreaterThan(2)
    .WithMessage("IntValue is not greater than 2"))

... and so on. What I'm trying to say is that in many cases the actual message would be quite predictable :D That's why I thought about populating the ErrorMessages array in the IValitResult with default messages. Of course using WithMessage() would replace that with the custom one. I guess that, this feature wouldn't work with the Error Codes because eveybody has completely different system for doing that.

I had some free time today and started the implementation in wip/feature/113.
For now only ValitRuleInt32Extensions.IsGreaterThan is implemented.

Whats bugging me the most is the way to get the IsGreaterThan value (in your example it would be 2).
For now I'm passing the value through Satisfies and I am wondering if there is a better way...

Like always, feedback is appreciated 😄