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

"Smart names" in the error message #1

Closed bartoszlenar closed 4 years ago

bartoszlenar commented 4 years ago

Feature description

Feature in action

Specification<decimal> specification = s => s
    .Positive()
    .WithPath("Number.Primary.SuperValue")
    .WithMessage("The {_name|format=friendly} needs to be positive!");

var validator = Validator.Factory.Create(specification);

var result = validator.Validate(-1);

result.ToString();
// Number.Primary.SuperValue: The Super Value needs to be positive!

Feature details

bartoszlenar commented 4 years ago

Solved. Solution based on https://stackoverflow.com/a/35953318/1633913 with extra custom fixes.