All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava3.ext.web.api.validation.ParameterValidationRule Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * 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.rxjava3.ext.web.api.validation;

import io.vertx.rxjava3.RxHelper;
import io.vertx.rxjava3.ObservableHelper;
import io.vertx.rxjava3.FlowableHelper;
import io.vertx.rxjava3.impl.AsyncResultMaybe;
import io.vertx.rxjava3.impl.AsyncResultSingle;
import io.vertx.rxjava3.impl.AsyncResultCompletable;
import io.vertx.rxjava3.WriteStreamObserver;
import io.vertx.rxjava3.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;

/**
 * This function is an inner wrapper for ParameterTypeValidator inside ValidationHandler parameter maps. Don't
 * instantiate this class, if you want to add custom ParameterTypeValidator to a parameter use functions in
 * {@link io.vertx.rxjava3.ext.web.api.validation.HTTPRequestValidationHandler}
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.api.validation.ParameterValidationRule original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.ext.web.api.validation.ParameterValidationRule.class) public class ParameterValidationRule { @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; ParameterValidationRule that = (ParameterValidationRule) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new ParameterValidationRule((io.vertx.ext.web.api.validation.ParameterValidationRule) obj), ParameterValidationRule::getDelegate ); private final io.vertx.ext.web.api.validation.ParameterValidationRule delegate; public ParameterValidationRule(io.vertx.ext.web.api.validation.ParameterValidationRule delegate) { this.delegate = delegate; } public ParameterValidationRule(Object delegate) { this.delegate = (io.vertx.ext.web.api.validation.ParameterValidationRule)delegate; } public io.vertx.ext.web.api.validation.ParameterValidationRule getDelegate() { return delegate; } /** * This function return the name of the parameter expected into parameter lists * @return name of the parameter */ @Deprecated() public java.lang.String getName() { java.lang.String ret = delegate.getName(); return ret; } /** * This function will be called when there is only a string as parameter. It will throw a ValidationError in an * error during validation occurs * @param value list of values that will be validated * @return */ @Deprecated() public io.vertx.rxjava3.ext.web.api.RequestParameter validateSingleParam(java.lang.String value) { io.vertx.rxjava3.ext.web.api.RequestParameter ret = io.vertx.rxjava3.ext.web.api.RequestParameter.newInstance((io.vertx.ext.web.api.RequestParameter)delegate.validateSingleParam(value)); return ret; } /** * This function will be called when there is a List that need to be validated. It must check if array is * expected or not. It will throw a ValidationError in an error during validation occurs * @param value list of values that will be validated * @return */ @Deprecated() public io.vertx.rxjava3.ext.web.api.RequestParameter validateArrayParam(java.util.List value) { io.vertx.rxjava3.ext.web.api.RequestParameter ret = io.vertx.rxjava3.ext.web.api.RequestParameter.newInstance((io.vertx.ext.web.api.RequestParameter)delegate.validateArrayParam(value)); return ret; } /** * Return true if parameter is optional * @return true if is optional, false otherwise */ @Deprecated() public boolean isOptional() { boolean ret = delegate.isOptional(); return ret; } /** * Return ParameterTypeValidator instance used inside this parameter validation rule * @return */ @Deprecated() public io.vertx.rxjava3.ext.web.api.validation.ParameterTypeValidator parameterTypeValidator() { io.vertx.rxjava3.ext.web.api.validation.ParameterTypeValidator ret = io.vertx.rxjava3.ext.web.api.validation.ParameterTypeValidator.newInstance((io.vertx.ext.web.api.validation.ParameterTypeValidator)delegate.parameterTypeValidator()); return ret; } /** * allowEmptyValue is used in query, header, cookie and form parameters. This is its behaviour: *

    *
  1. During validation, the ValidationHandler check if there's a parameter with combination of location and name * as defined in this rule
  2. *
  3. If it not exists, It will check allowEmptyValue and if there's a default value set inside * ParameterTypeValidator:
  4. *
      *
    • If this condition it's true, It marks as validated the parameter and returns the default value (inside * RequestParameter)
    • *
    • If this condition it's false, It throws ValidationException
    • *
    *
  5. If the parameter exists, It checks if parameter is null or empty string:
  6. *
      *
    • If allowEmptyValue it's true, It marks as validated the parameter and returns the default value if it exists * (inside RequestParameter)
    • *
    • If allowEmptyValue it's false, It throws ValidationException
    • *
    *
* @return value of allowEmptyValue */ @Deprecated() public boolean allowEmptyValue() { boolean ret = delegate.allowEmptyValue(); return ret; } public static ParameterValidationRule newInstance(io.vertx.ext.web.api.validation.ParameterValidationRule arg) { return arg != null ? new ParameterValidationRule(arg) : null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy