You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking through your library and noticed a couple of minor things that you may want to consider for better integration with FluentValidation.
If you wanted to support InjectValidator, then you could pass the service provider into the ValidationContext
FluentValidator.CreateValidationContext could be simplified so you don't have to use reflection.
private IValidationContext CreateValidationContext(objectmodel,IValidatorSelectorvalidatorSelector=null){if(validatorSelector==null){// No selector specified - use the default.validatorSelector= ValidatorOptions.Global.ValidatorSelectors.DefaultValidatorSelectorFactory()}// Don't need to use reflection to construct the context. // If you create it as a ValidationContext<object> instead of a ValidationContext<T> then FluentValidation will perform the conversion internally, assuming the types are compatible.
var context =new ValidationContext<object>(model,new PropertyChain(), validatorSelector);// InjectValidator looks for a service provider inside the ValidationContext with this key.
context.RootContextData["_FV_ServiceProvider"]=ServiceProvider;returncontext;}
Hope that's useful
The text was updated successfully, but these errors were encountered:
Hi @ryanelian,
I was looking through your library and noticed a couple of minor things that you may want to consider for better integration with FluentValidation.
InjectValidator
, then you could pass the service provider into the ValidationContextFluentValidator.CreateValidationContext
could be simplified so you don't have to use reflection.Hope that's useful
The text was updated successfully, but these errors were encountered: