Love FluentValidators but one feature I believe is missing.
A lot of time my validations requires some lookup in a database or conversion from string “SALE” => OprationTypeEnum.Sale.
Is it possible to carry additional “context” object that will be populated as my validation goes along.


An example. I get DTO with orderID:1025. I did a lookup, checked that orderId is valid, and populated my “context” object with order information. I did a lookup in DB anyway, why not to retrieve additional info.
Otherwise i have to do lookup again after my DTO successfully passed validation.
Something like this:
I don’t see why not. Just use the IHttpContextAccessor and place it on your context object. But why do you want to do this? Why not just let it pass validation and check it once in your handler?
IHttpContextAccessor
That is not what i had in mind. Plus my desktop app might not even have it.
More of something like that.
How about caching your Db layer, so a 2nd lookup doesn’t hit the db?
C# devs
null reference exceptions

source