public static void TryCheckTooManyParameters(TransformRouteValidationContext context, IReadOnlyDictionary <string, string> rawTransform, int expected) { if (rawTransform.Count > expected) { context.Errors.Add(new InvalidOperationException("The transform contains more parameters than expected: " + string.Join(';', rawTransform.Keys))); } }
/// <inheritdoc/> public IReadOnlyList <Exception> ValidateRoute(RouteConfig route) { var context = new TransformRouteValidationContext() { Services = _services, Route = route, }; var rawTransforms = route?.Transforms; if (rawTransforms?.Count > 0) { foreach (var rawTransform in rawTransforms) { var handled = false; foreach (var factory in _factories) { if (factory.Validate(context, rawTransform)) { handled = true; break; } } if (!handled) { context.Errors.Add(new ArgumentException($"Unknown transform: {string.Join(';', rawTransform.Keys)}")); } } } // Let the app add any more validation it wants. foreach (var transformProvider in _providers) { transformProvider.ValidateRoute(context); } // We promise not to modify the list after we return it. return((IReadOnlyList <Exception>)context.Errors); }
public void ValidateRoute(TransformRouteValidationContext context) { }