public static IValidatorFactory GetValidatorFactory(this IValidationContext context)
        {
            var factory = context.GetServiceProvider().GetValidatorFactory()
                          ?? ServiceLocator.GetValidatorFactory();

            if (factory == null)
            {
                throw new InvalidOperationException("Could not get a validator factory. Either use a ValidationContextProvider or register a global validator factory in ServiceLocator.");
            }

            return(factory);
        }
 public static ILiteralService GetLiteralService(this IValidationContext context)
 {
     return(context.GetServiceProvider().GetRequiredService <ILiteralService>());
 }