vertx/src/main/java/eu/internetofus/common/vertx/OpenAPIValidator.java
/**
   * Validate that the value is any of the specified values.
   *
   * @param promise     to inform of the validation.
   * @param environment to use for the validation.
   *
   * @return the future that says if the value is valid or not.
   */
Validate that the value is any of the specified values.
@param promise     to inform of the validation.
@param environment to use for the validation.

@return the future that says if the value is valid or not.
Validate that the value is any of the specified values . @param promise to inform of the validation . @param environment to use for the validation . @return the future that says if the value is valid or not .
static private Future<ValueEnvironment> validateAnyOfValue(@NotNull final Promise<ValueEnvironment> promise,
      @NotNull final ValueEnvironment environment) {
    var future = promise.future();
    final var anyOf = environment.specification.getJsonArray("anyOf");
    final var max = anyOf.size();
    for (var i = 0; i < max; i++) {
      final var type = anyOf.getJsonObject(i);
      final var subEnvironment = new ValueEnvironment(environment.codePrefix, environment.vertx, type,
          environment.value);
      subEnvironment.checkingCompose = true;
      future = future
          .compose(chain -> composeValidation(Future.succeededFuture(subEnvironment), OpenAPIValidator::validateValue)
              .transform(subResult -> {
                if (subResult.succeeded()) {
                  final var result = subResult.result();
                  chain.value = result.value;
                  chain.succedCompose++;
                  chain.addFieldNames(result);
                }
                return Future.succeededFuture(chain);
              }));
    }
    future = future.compose(chain -> {
      if (chain.succedCompose > 0) {
        chain.succedCompose = 0;
        return Future.succeededFuture(chain);
      } else {
        return Future.failedFuture(chain.notValid("The value does not match any of the possible values"));
      }
    });
    return future;
  }
static private Future < ValueEnvironment > validateAnyOfValue ( @ NotNull final Promise < ValueEnvironment > promise , @ NotNull final ValueEnvironment environment ) { var future = promise . future ( ) ; final var anyOf = environment . specification . getJsonArray ( "anyOf" ) ; final var max = anyOf . size ( ) ; for ( var i = 0 ; i < max ; i ++ ) { final var type = anyOf . getJsonObject ( i ) ; final var subEnvironment = new ValueEnvironment ( environment . codePrefix , environment . vertx , type , environment . value ) ; subEnvironment . checkingCompose = true ; future = future . compose ( chain -> composeValidation ( Future . succeededFuture ( subEnvironment ) , OpenAPIValidator :: validateValue ) . transform ( subResult -> { if ( subResult . succeeded ( ) ) { final var result = subResult . result ( ) ; chain . value = result . value ; chain . succedCompose ++ ; chain . addFieldNames ( result ) ; } return Future . succeededFuture ( chain ) ; } ) ) ; } future = future . compose ( chain -> { if ( chain . succedCompose > 0 ) { chain . succedCompose = 0 ; return Future . succeededFuture ( chain ) ; } else { return Future . failedFuture ( chain . notValid ( "The value does not match any of the possible values" ) ) ; } } ) ; return future ; }
Validate that the value is any of the specified values.
Validate that the value is any of the specified values .