My previous breakthrough note about validation in .NET was written under the influence of the client-side need to implement
INotifyDataErrorInfo without really paying proper respect for
System.ComponentModel.DataAnnotations.Validator. I had to pay my respects eventually.
Here’s my big, respectful, swaggering, flippant remark about .NET validation: a
ValidationContext is needed to pass to
Validator.TryValidate*() methods to yield
IEnumerable<ValidationResult>. This flippant remark reveals intent. I attempted to express this intent in my new
ToValidationResults() extension methods (that yield
IEnumerable<ValidationResult>) should—I repeat should—work with
INotifyDataErrorInfo.GetErrors() (which works fine with
IEnumerable<string>). Once I get a bit of time to verify this, it will confirm that my new
ValidationContextExtensions class is the final piece of my Validation puzzle that works with .NET Data Annotations on the server side as well as the Client side.
I placed this new class in my Core library instead of my Data Access library because this is devoted to Model (or View Model) validation in memory, having nothing to do with the access of data across a boundary.