model/src/main/java/eu/internetofus/common/model/ValidateContext.java
/**
   * Verify an enumeration field.
   *
   * @param fieldName      name of the checking field.
   * @param value          to verify.
   * @param promise        to notify of any error.
   * @param possibleValues values that can have the value.
   *
   * @param <T>            type of possible values.
   */
Verify an enumeration field.
@param fieldName      name of the checking field.
@param value          to verify.
@param promise        to notify of any error.
@param possibleValues values that can have the value.

@param             type of possible values.
Verify an enumeration field . @param fieldName name of the checking field . @param value to verify . @param promise to notify of any error . @param possibleValues values that can have the value . @param type of possible values .
default <T> void validateEnumField(final String fieldName, final T value, final Promise<Void> promise,
      @SuppressWarnings("unchecked") final T... possibleValues) {
    if (!Arrays.stream(possibleValues).anyMatch(element -> value.equals(element))) {
      promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName),
          "'" + value + "' is not a valid value, because it is not in '" + Arrays.toString(possibleValues) + "'."));
    }
  }
default < T > void validateEnumField ( final String fieldName , final T value , final Promise < Void > promise , @ SuppressWarnings ( "unchecked" ) final T ... possibleValues ) { if ( ! Arrays . stream ( possibleValues ) . anyMatch ( element -> value . equals ( element ) ) ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "'" + value + "' is not a valid value, because it is not in '" + Arrays . toString ( possibleValues ) + "'." ) ) ; } }
Verify an enumeration field.
Verify an enumeration field .