components/src/main/java/eu/internetofus/common/components/WeNetValidateContext.java
/**
   * Check if a field contains a defined model.
   *
   * @param name   of the field to validate.
   * @param id     identifier of the model.
   * @param type   of model to search.
   * @param search function to check if the model exist.
   * @param future to compose if the profile is defined or not.
   *
   * @return the future with the validation result.
   */
Check if a field contains a defined model.
@param name   of the field to validate.
@param id     identifier of the model.
@param type   of model to search.
@param search function to check if the model exist.
@param future to compose if the profile is defined or not.

@return the future with the validation result.
Check if a field contains a defined model . @param name of the field to validate . @param id identifier of the model . @param type of model to search . @param search function to check if the model exist . @param future to compose if the profile is defined or not . @return the future with the validation result .
public Future<Void> validateDefinedIdField(final String name, final String id, final Class<?> type,
      final Function<String, Future<Boolean>> search, final Future<Void> future) {
    final var key = this.generateKey(id, type);
    if (this.idsCache.contains(key)) {
      return future;
    } else {
      return future.compose(empty -> search.apply(id).transform(defined -> {
        if (defined.failed()) {
          return this.failField(name, defined.cause());
        } else if (defined.result() == true) {
          this.idsCache.add(key);
          return Future.succeededFuture();
        } else {
          return this.failField(name, "The '" + id + "' is not associated to any model.");
        }
      }));
    }
  }
public Future < Void > validateDefinedIdField ( final String name , final String id , final Class < ? > type , final Function < String , Future < Boolean > > search , final Future < Void > future ) { final var key = this . generateKey ( id , type ) ; if ( this . idsCache . contains ( key ) ) { return future ; } else { return future . compose ( empty -> search . apply ( id ) . transform ( defined -> { if ( defined . failed ( ) ) { return this . failField ( name , defined . cause ( ) ) ; } else if ( defined . result ( ) == true ) { this . idsCache . add ( key ) ; return Future . succeededFuture ( ) ; } else { return this . failField ( name , "The '" + id + "' is not associated to any model." ) ; } } ) ) ; } }
Check if a field contains a defined model.
Check if a field contains a defined model .