Closed kimsagro1 closed 3 years ago
You'll need to use the synchronous version of the repository method in FluentValidation validators. I'd just keep the single (sync) version of GetAllStates()
, but if the performance/throughput is crucial for the project, you can also introduce an async version (GetAllStatesAsync()
) for the use in controllers.
you can also introduce an async version (GetAllStatesAsync()) for the use in controllers
So at this point you have the move all the validation out of the fluent validator into the controller, right?
No, I would just keep using the sync version in the validators, but if I need an async version (for the use in controllers), then I'd introduce an async version. But that's only if it really makes a difference in terms of performance or throughput. Otherwise, just use the sync version everywhere.
FluentValidator's integration with ASP.NET Core has a major caveat
Within the
RegisterRequestValidator
you call theStateRepository
to get all the states. This is currently a synchronous call but I imagine in most real world scenarios this would be an asynchronous call.I'm curious how you would you handle this scenario?