This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Consider flowing IServiceProvider through the ValidationContext
created in DataAnnotationsModelValidatorProvider
#1682
Closed
Description
In the implementation of IValidatableObject.Validate
\ custom ValidateAttribute
, all you get is an instance of ValidationContext
. Short of using CallContextServiceLocator
, there is no way to get to services that could be used as part of validation.
ValidationContext
does support a way to pass in an IServiceProvider
and consume it as part of validation. We should modify DataAnnotationsModelValidatorProvider
to pass in HttpContext.RequestServices
as the IServiceProvider
when setting up the ModelValidationContext
instance.