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

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

There is a newer version: 4.5.11
Show newest version
package io.vertx.ext.web.api.validation;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.ext.web.api.RequestParameter;

import java.util.List;

/**
 * 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 HTTPRequestValidationHandler}
 *
 * @author Francesco Guardiani @slinkydeveloper
 * @deprecated You should use the new module vertx-web-openapi
 */
@VertxGen
@Deprecated
public interface ParameterValidationRule {

  /**
   * This function return the name of the parameter expected into parameter lists
   *
   * @return name of the parameter
   */
  String getName();

  /**
   * 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
   * @throws ValidationException
   */
  RequestParameter validateSingleParam(String value) throws ValidationException;

  /**
   * 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
   * @throws ValidationException
   */
  RequestParameter validateArrayParam(List value) throws ValidationException;

  /**
   * Return true if parameter is optional
   *
   * @return true if is optional, false otherwise
   */
  boolean isOptional();

  /**
   * Return ParameterTypeValidator instance used inside this parameter validation rule
   *
   * @return
   */
  ParameterTypeValidator parameterTypeValidator();

  /**
   * 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 */ boolean allowEmptyValue(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy