Exemplo n.º 1
0
        /// <summary>Validates the specified API request context resolver.</summary>
        /// <param name="apiRequestContextResolver">The API request context resolver.</param>
        /// <returns></returns>
        public Task <IList <ApiValidationResult> > Validate(IApiRequestContextResolver apiRequestContextResolver)
        {
            var context             = apiRequestContextResolver?.GetContext();
            var suggestedStatusCode = context.Configuration.ValidationErrorConfiguration.UriBindingErrorStatusCode;

            return(Task.FromResult(ApiValidationResult.Single("VALIDATOR-3", suggestedHttpStatusCode: suggestedStatusCode)));
        }
Exemplo n.º 2
0
        /// <summary>Validates the specified API request context resolver.</summary>
        /// <param name="contextResolver">The API request context resolver.</param>
        /// <returns></returns>
        public Task <IList <ApiValidationResult> > Validate(IApiRequestContextResolver contextResolver)
        {
            var context = contextResolver.GetContext();
            var body    = context.Request.InvocationContext.Models <DataAnnotationsBodyModel>().FirstOrDefault();
            var uri     = context.Request.InvocationContext.Models <DataAnnotationsUriModel>().FirstOrDefault();

            if (body.Value != uri.Value)
            {
                return(Task.FromResult(ApiValidationResult.Single("Body value and Uri value must be the same")));
            }

            return(Task.FromResult(ApiValidationResult.Success()));
        }
Exemplo n.º 3
0
 /// <summary>Validates the specified API request context resolver.</summary>
 /// <param name="contextResolver">The API request context resolver.</param>
 /// <returns></returns>
 public Task <IList <ApiValidationResult> > Validate(IApiRequestContextResolver contextResolver)
 {
     return(Task.FromResult(ApiValidationResult.Single("VALIDATOR-5", suggestedHttpStatusCode: 404)));
 }
Exemplo n.º 4
0
 public Task <IList <ApiValidationResult> > Validate(IApiRequestContextResolver contextResolver)
 {
     return(Task.FromResult(ApiValidationResult.Single("VALIDATOR-1")));
 }