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

@return the future that says if the string is valid or not.
Validate that the value is a valid string . @param promise to inform of the validation . @param environment to use for the validation . @return the future that says if the string is valid or not .
static Future<ValueEnvironment> validateStringValue(@NotNull final Promise<ValueEnvironment> promise,
      @NotNull final ValueEnvironment environment) {
    if (environment.value instanceof String) {
      final var value = (String) environment.value;
      final var pattern = environment.specification.getString("pattern", null);
      if (pattern != null && !value.matches(pattern)) {
        promise.fail(environment.notValid("The value does not match the pattern."));
      } else {
        final var min = environment.specification.getInteger("minLength", null);
        if (min != null && value.length() < min) {
          promise.fail(environment.notValid("The value has to have a length equal or greater than " + min + "."));
        } else {
          final var max = environment.specification.getInteger("maxLength", null);
          if (max != null && value.length() > max) {
            promise.fail(environment.notValid("The value has to have a length equal or less than " + max + "."));
          } else {
            environment.match = true;
          }
        }
      }
    } else {
      promise.fail(environment.notValid("Expecting a 'string' value."));
    }
    return promise.future();
  }
static Future < ValueEnvironment > validateStringValue ( @ NotNull final Promise < ValueEnvironment > promise , @ NotNull final ValueEnvironment environment ) { if ( environment . value instanceof String ) { final var value = ( String ) environment . value ; final var pattern = environment . specification . getString ( "pattern" , null ) ; if ( pattern != null && ! value . matches ( pattern ) ) { promise . fail ( environment . notValid ( "The value does not match the pattern." ) ) ; } else { final var min = environment . specification . getInteger ( "minLength" , null ) ; if ( min != null && value . length ( ) < min ) { promise . fail ( environment . notValid ( "The value has to have a length equal or greater than " + min + "." ) ) ; } else { final var max = environment . specification . getInteger ( "maxLength" , null ) ; if ( max != null && value . length ( ) > max ) { promise . fail ( environment . notValid ( "The value has to have a length equal or less than " + max + "." ) ) ; } else { environment . match = true ; } } } } else { promise . fail ( environment . notValid ( "Expecting a 'string' value." ) ) ; } return promise . future ( ) ; }
Validate that the value is a valid string.
Validate that the value is a valid string .