/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.reactivex.ext.web.api.validation;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
An interface for add HTTP Request validation. This class can validate parameters inside query, path, headers an
body (watch below)
You can assign multiple body type at the same time(for example a JSON schema together with a XML schema). This
interface support:
- application/x-www-form-urlencoded
- multipart/form-data
- application/xml
- application/json
Also you can add a form parameter for validation without care about content type of your request. For form
parameters this interface support both "multipart/form-data" and "application/x-www-form-urlencoded"
This interface allow extra parameters in the request, so it doesn't care if in a request there's a parameter
without a specified validation rule
If a parameter is flagged as an array, it will be validated also if the size of array is 1 element
NOTE: This class has been automatically generated from the original
non RX-ified interface using Vert.x codegen. /**
* An interface for add HTTP Request validation. This class can validate parameters inside query, path, headers an
* body (watch below)
* <br/>
* You can assign multiple body type at the same time(for example a JSON schema together with a XML schema). This
* interface support:
* <ul>
* <li>application/x-www-form-urlencoded</li>
* <li>multipart/form-data</li>
* <li>application/xml</li>
* <li>application/json</li>
* </ul>
* Also you can add a form parameter for validation without care about content type of your request. For form
* parameters this interface support both "multipart/form-data" and "application/x-www-form-urlencoded"
* <br/>
* This interface allow extra parameters in the request, so it doesn't care if in a request there's a parameter
* without a specified validation rule
* <br/>
* If a parameter is flagged as an array, it will be validated also if the size of array is 1 element
*
* <p/>
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.api.validation.HTTPRequestValidationHandler original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.ext.web.api.validation.HTTPRequestValidationHandler.class)
public class HTTPRequestValidationHandler implements io.vertx.reactivex.ext.web.api.validation.ValidationHandler, Handler<io.vertx.reactivex.ext.web.RoutingContext> {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HTTPRequestValidationHandler that = (HTTPRequestValidationHandler) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<HTTPRequestValidationHandler> __TYPE_ARG = new TypeArg<>( obj -> new HTTPRequestValidationHandler((io.vertx.ext.web.api.validation.HTTPRequestValidationHandler) obj),
HTTPRequestValidationHandler::getDelegate
);
private final io.vertx.ext.web.api.validation.HTTPRequestValidationHandler delegate;
public HTTPRequestValidationHandler(io.vertx.ext.web.api.validation.HTTPRequestValidationHandler delegate) {
this.delegate = delegate;
}
public HTTPRequestValidationHandler(Object delegate) {
this.delegate = (io.vertx.ext.web.api.validation.HTTPRequestValidationHandler)delegate;
}
public io.vertx.ext.web.api.validation.HTTPRequestValidationHandler getDelegate() {
return delegate;
}
Something has happened, so handle it.
Params: - event – the event to handle
/**
* Something has happened, so handle it.
* @param event the event to handle
*/
@Deprecated()
public void handle(io.vertx.reactivex.ext.web.RoutingContext event) {
delegate.handle(event.getDelegate());
}
Factory method to create an HTTPRequestValidationHandler
Returns: new HTTPRequestValidationHandler
/**
* Factory method to create an HTTPRequestValidationHandler
* @return new HTTPRequestValidationHandler
*/
@Deprecated()
public static io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler create() {
io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler ret = io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler.newInstance((io.vertx.ext.web.api.validation.HTTPRequestValidationHandler)io.vertx.ext.web.api.validation.HTTPRequestValidationHandler.create());
return ret;
}
Add a path parameter with included parameter types. All path params are required
Params: - parameterName – expected name of parameter inside the path
- type – expected type of parameter
Returns: this handler
/**
* Add a path parameter with included parameter types. All path params are <b>required</b>
* @param parameterName expected name of parameter inside the path
* @param type expected type of parameter
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addPathParam(String parameterName, io.vertx.ext.web.api.validation.ParameterType type) {
delegate.addPathParam(parameterName, type);
return this;
}
Add a path parameter with a custom pattern. All path params are required
Params: - parameterName – expected name of parameter inside the path
- pattern – regular expression for validation
Returns: this handler
/**
* Add a path parameter with a custom pattern. All path params are <b>required</b>
* @param parameterName expected name of parameter inside the path
* @param pattern regular expression for validation
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addPathParamWithPattern(String parameterName, String pattern) {
delegate.addPathParamWithPattern(parameterName, pattern);
return this;
}
Add a path parameter with a custom type validator. All path params are required. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Params: - parameterName – expected name of parameter inside the path
- validator – type validator
- allowEmptyValue – true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour:
ParameterValidationRule.allowEmptyValue
Returns: this handler
/**
* Add a path parameter with a custom type validator. All path params are <b>required</b>. For more informations
* about how to construct built-in or custom type validator, check out {@link io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator}
* @param parameterName expected name of parameter inside the path
* @param validator type validator
* @param allowEmptyValue true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: {@link io.vertx.reactivex.ext.web.api.validation.ParameterValidationRule#allowEmptyValue}
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addPathParamWithCustomTypeValidator(String parameterName, io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator validator, boolean allowEmptyValue) {
delegate.addPathParamWithCustomTypeValidator(parameterName, validator.getDelegate(), allowEmptyValue);
return this;
}
Add a query parameter with included parameter types
Params: - parameterName – expected name of parameter inside the query
- type – expected type of parameter
- required – true if parameter is required
Returns: this handler
/**
* Add a query parameter with included parameter types
* @param parameterName expected name of parameter inside the query
* @param type expected type of parameter
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addQueryParam(String parameterName, io.vertx.ext.web.api.validation.ParameterType type, boolean required) {
delegate.addQueryParam(parameterName, type, required);
return this;
}
Add a query parameter with a custom pattern
Params: - parameterName – expected name of parameter inside the query
- pattern – regular expression for validation
- required – true if parameter is required
Returns: this handler
/**
* Add a query parameter with a custom pattern
* @param parameterName expected name of parameter inside the query
* @param pattern regular expression for validation
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addQueryParamWithPattern(String parameterName, String pattern, boolean required) {
delegate.addQueryParamWithPattern(parameterName, pattern, required);
return this;
}
Add a query parameters array with included parameter types
Params: - arrayName – expected name of array inside the query
- type – expected type of parameter
- required – true if parameter is required
Returns: this handler
/**
* Add a query parameters array with included parameter types
* @param arrayName expected name of array inside the query
* @param type expected type of parameter
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addQueryParamsArray(String arrayName, io.vertx.ext.web.api.validation.ParameterType type, boolean required) {
delegate.addQueryParamsArray(arrayName, type, required);
return this;
}
Add a query parameters array with a custom pattern
Params: - arrayName – expected name of array inside the query
- pattern – regular expression for validation
- required – true if parameter is required
Returns: this handler
/**
* Add a query parameters array with a custom pattern
* @param arrayName expected name of array inside the query
* @param pattern regular expression for validation
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addQueryParamsArrayWithPattern(String arrayName, String pattern, boolean required) {
delegate.addQueryParamsArrayWithPattern(arrayName, pattern, required);
return this;
}
Add a query parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Params: - parameterName – expected name of parameter inside the query
- validator – type validator
- required – true if parameter is required
- allowEmptyValue – true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour:
ParameterValidationRule.allowEmptyValue
Returns: this handler
/**
* Add a query parameter with a custom type validator. For more informations about how to construct built-in or
* custom type validator, check out {@link io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator}
* @param parameterName expected name of parameter inside the query
* @param validator type validator
* @param required true if parameter is required
* @param allowEmptyValue true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: {@link io.vertx.reactivex.ext.web.api.validation.ParameterValidationRule#allowEmptyValue}
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addQueryParamWithCustomTypeValidator(String parameterName, io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator validator, boolean required, boolean allowEmptyValue) {
delegate.addQueryParamWithCustomTypeValidator(parameterName, validator.getDelegate(), required, allowEmptyValue);
return this;
}
Add a header parameter with included parameter types
Params: - headerName – expected header name
- type – expected type of parameter
- required – true if parameter is required
Returns: this handler
/**
* Add a header parameter with included parameter types
* @param headerName expected header name
* @param type expected type of parameter
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addHeaderParam(String headerName, io.vertx.ext.web.api.validation.ParameterType type, boolean required) {
delegate.addHeaderParam(headerName, type, required);
return this;
}
Add a header parameter with a custom pattern
Params: - headerName – expected header name
- pattern – regular expression for validation
- required – true if parameter is required
Returns: this handler
/**
* Add a header parameter with a custom pattern
* @param headerName expected header name
* @param pattern regular expression for validation
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addHeaderParamWithPattern(String headerName, String pattern, boolean required) {
delegate.addHeaderParamWithPattern(headerName, pattern, required);
return this;
}
Add a header parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Params: - headerName – expected header namery
- validator – type validator
- required – true if parameter is required
- allowEmptyValue – true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour:
ParameterValidationRule.allowEmptyValue
Returns: this handler
/**
* Add a header parameter with a custom type validator. For more informations about how to construct built-in or
* custom type validator, check out {@link io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator}
* @param headerName expected header namery
* @param validator type validator
* @param required true if parameter is required
* @param allowEmptyValue true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: {@link io.vertx.reactivex.ext.web.api.validation.ParameterValidationRule#allowEmptyValue}
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addHeaderParamWithCustomTypeValidator(String headerName, io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator validator, boolean required, boolean allowEmptyValue) {
delegate.addHeaderParamWithCustomTypeValidator(headerName, validator.getDelegate(), required, allowEmptyValue);
return this;
}
Add a single parameter inside a form with included parameter types
Params: - parameterName – expected name of parameter inside the form
- type – expected type of parameter
- required – true if parameter is required
Returns: this handler
/**
* Add a single parameter inside a form with included parameter types
* @param parameterName expected name of parameter inside the form
* @param type expected type of parameter
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addFormParam(String parameterName, io.vertx.ext.web.api.validation.ParameterType type, boolean required) {
delegate.addFormParam(parameterName, type, required);
return this;
}
Add a single parameter inside a form with a custom pattern
Params: - parameterName – expected name of parameter inside the form
- pattern – regular expression for validation
- required – true if parameter is required
Returns: this handler
/**
* Add a single parameter inside a form with a custom pattern
* @param parameterName expected name of parameter inside the form
* @param pattern regular expression for validation
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addFormParamWithPattern(String parameterName, String pattern, boolean required) {
delegate.addFormParamWithPattern(parameterName, pattern, required);
return this;
}
Add a form parameters array with included parameter types
Params: - parameterName – expected name of array of parameters inside the form
- type – expected type of array of parameters
- required – true if parameter is required
Returns: this handler
/**
* Add a form parameters array with included parameter types
* @param parameterName expected name of array of parameters inside the form
* @param type expected type of array of parameters
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addFormParamsArray(String parameterName, io.vertx.ext.web.api.validation.ParameterType type, boolean required) {
delegate.addFormParamsArray(parameterName, type, required);
return this;
}
Add a form parameters array with a custom pattern
Params: - parameterName – expected name of array of parameters inside the form
- pattern – regular expression for validation
- required – true if parameter is required
Returns: this handler
/**
* Add a form parameters array with a custom pattern
* @param parameterName expected name of array of parameters inside the form
* @param pattern regular expression for validation
* @param required true if parameter is required
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addFormParamsArrayWithPattern(String parameterName, String pattern, boolean required) {
delegate.addFormParamsArrayWithPattern(parameterName, pattern, required);
return this;
}
Add a form parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Params: - parameterName – expected name of parameter inside the form
- validator – type validator
- required – true if parameter is required
- allowEmptyValue – true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour:
ParameterValidationRule.allowEmptyValue
Returns: this handler
/**
* Add a form parameter with a custom type validator. For more informations about how to construct built-in or
* custom type validator, check out {@link io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator}
* @param parameterName expected name of parameter inside the form
* @param validator type validator
* @param required true if parameter is required
* @param allowEmptyValue true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: {@link io.vertx.reactivex.ext.web.api.validation.ParameterValidationRule#allowEmptyValue}
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addFormParamWithCustomTypeValidator(String parameterName, io.vertx.reactivex.ext.web.api.validation.ParameterTypeValidator validator, boolean required, boolean allowEmptyValue) {
delegate.addFormParamWithCustomTypeValidator(parameterName, validator.getDelegate(), required, allowEmptyValue);
return this;
}
Add a custom validator. For more informations about custom validator, see CustomValidator
Params: - customValidator –
Returns: this handler
/**
* Add a custom validator. For more informations about custom validator, see {@link io.vertx.reactivex.ext.web.api.validation.CustomValidator}
* @param customValidator
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addCustomValidatorFunction(io.vertx.reactivex.ext.web.api.validation.CustomValidator customValidator) {
delegate.addCustomValidatorFunction(customValidator.getDelegate());
return this;
}
Add a json schema for body with Content-Type "application/json"
Params: - jsonSchema –
Returns: this handler
/**
* Add a json schema for body with Content-Type "application/json"
* @param jsonSchema
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addJsonBodySchema(String jsonSchema) {
delegate.addJsonBodySchema(jsonSchema);
return this;
}
Add a xml schema for body with Content-Type "application/xml"
Params: - xmlSchema –
Returns: this handler
/**
* Add a xml schema for body with Content-Type "application/xml"
* @param xmlSchema
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addXMLBodySchema(String xmlSchema) {
delegate.addXMLBodySchema(xmlSchema);
return this;
}
Add an expected filename inside multipart request.
Params: - filename – name of the file inside the form
- contentType – expected content type of file
Returns: this handler
/**
* Add an expected filename inside <b>multipart request</b>.
* @param filename name of the file inside the form
* @param contentType expected content type of file
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addMultipartRequiredFile(String filename, String contentType) {
delegate.addMultipartRequiredFile(filename, contentType);
return this;
}
Add an expected content type of request. It's not needed to add application/json, application/xml,
multipart/form-data and application/x-www-form-urlencoded
Params: - contentType – expected content type of file
Returns: this handler
/**
* Add an expected content type of request. It's not needed to add application/json, application/xml,
* multipart/form-data and application/x-www-form-urlencoded
* @param contentType expected content type of file
* @return this handler
*/
@Deprecated()
public io.vertx.reactivex.ext.web.api.validation.HTTPRequestValidationHandler addExpectedContentType(String contentType) {
delegate.addExpectedContentType(contentType);
return this;
}
public static HTTPRequestValidationHandler newInstance(io.vertx.ext.web.api.validation.HTTPRequestValidationHandler arg) {
return arg != null ? new HTTPRequestValidationHandler(arg) : null;
}
}