vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Validate a model.
   *
   * @param model   context of the model to validate.
   * @param context of the request.
   * @param success component to call if the model is valid.
   *
   * @param <T>     type of model to validate.
   * @param <I>     type for the model identifier.
   * @param <C>     type of validation context to use.
   */
Validate a model.
@param model   context of the model to validate.
@param context of the request.
@param success component to call if the model is valid.

@param      type of model to validate.
@param      type for the model identifier.
@param      type of validation context to use.
Validate a model . @param model context of the model to validate . @param context of the request . @param success component to call if the model is valid . @param type of model to validate . @param type for the model identifier . @param type of validation context to use .
static public <C extends ValidateContext<C>, T extends Model & Validable<C>, I> void validate(
      @NotNull final ModelContext<T, I, C> model, @NotNull final ServiceContext context,
      @NotNull final Runnable success) {
    model.source.validate(model.validateContext).onComplete(valid -> {
      if (valid.failed()) {
        final var cause = valid.cause();
        Logger.trace(cause, "The {} is not valid.\n{}", model, context);
        ServiceResponseHandlers.responseFailedWith(context.resultHandler, Status.BAD_REQUEST, cause);
      } else {
        model.value = model.source;
        success.run();
      }
    });
  }
static public < C extends ValidateContext < C > , T extends Model & Validable < C > , I > void validate ( @ NotNull final ModelContext < T , I , C > model , @ NotNull final ServiceContext context , @ NotNull final Runnable success ) { model . source . validate ( model . validateContext ) . onComplete ( valid -> { if ( valid . failed ( ) ) { final var cause = valid . cause ( ) ; Logger . trace ( cause , "The {} is not valid.\n{}" , model , context ) ; ServiceResponseHandlers . responseFailedWith ( context . resultHandler , Status . BAD_REQUEST , cause ) ; } else { model . value = model . source ; success . run ( ) ; } } ) ; }
Validate a model.
Validate a model .