bartoszlenar / Validot

Validot is a performance-first, compact library for advanced model validation. Using a simple declarative fluent interface, it efficiently handles classes, structs, nested members, collections, nullables, plus any relation or combination of them. It also supports translations, custom logic extensions with tests, and DI containers.
MIT License
311 stars 19 forks source link

WithSeverity - support for errors severity level #4

Closed bartoszlenar closed 4 years ago

bartoszlenar commented 4 years ago

Feature description

Feature in action

Specification<string> specification = s => s
    .NotEmpty().WithSeverity(10)
    .NotWhitespace().WithSeverity(0)
Specification<string> specification = s => s
    .NotEmpty().WithSeverity(Severity.High)
    .NotWhitespace().WithSeverity(Severity.Low)
result.AnyErrorsWithSeverity(Severity.High);

result.AnyErrorsWithSeverity(10);

result.GetMessageMapWithSeverity(Severity.Medium | Severity.High)

Feature details

bartoszlenar commented 4 years ago

At least for now, I'm closing the issue.

I explained the reason in the original description. Severities feature does bring extra complexity to the mechanism that should be reasonably simple. If one group of errors is more important than the other, some ways effectively will lead to the same effect:

This issue, though, sparked some ideas for the new features: