model/src/main/java/eu/internetofus/common/model/ValidateContext.java
/**
   * Validate that a number value is on the specified range.
   *
   * @param fieldName name of the checking field.
   * @param value     to verify.
   * @param minValue  minimum value, inclusive, of the range the value can be
   *                  defined, or {@code null} if not have minimum.
   * @param maxValue  maximum value, inclusive, of the range the value can be
   *                  defined, or {@code null} if not have maximum.
   * @param promise   to notify of any error.
   *
   * @param <T>       type of number to validate.
   */
Validate that a number value is on the specified range.
@param fieldName name of the checking field.
@param value     to verify.
@param minValue  minimum value, inclusive, of the range the value can be
defined, or  null if not have minimum.
@param maxValue  maximum value, inclusive, of the range the value can be
defined, or  null if not have maximum.
@param promise   to notify of any error.

@param        type of number to validate.
Validate that a number value is on the specified range . @param fieldName name of the checking field . @param value to verify . @param minValue minimum value inclusive of the range the value can be defined or null if not have minimum . @param maxValue maximum value inclusive of the range the value can be defined or null if not have maximum . @param promise to notify of any error . @param type of number to validate .
default <T extends Number> void validateNumberOnRangeField(final String fieldName, final T value, final T minValue,
      final T maxValue, final Promise<Void> promise) {
    if (value == null) {
      promise.tryFail(
          new ValidationErrorException(this.fieldErrorCode(fieldName), "The '" + fieldName + "' has to be defined."));
    } else if (minValue != null && value.doubleValue() < minValue.doubleValue()) {
      promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName),
          "The '" + value + "' is not valid because it is less than '" + minValue + "'."));
    } else if (maxValue != null && value.doubleValue() > maxValue.doubleValue()) {
      promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName),
          "The '" + value + "' is not valid because it is greater than '" + maxValue + "'."));
    }
  }
default < T extends Number > void validateNumberOnRangeField ( final String fieldName , final T value , final T minValue , final T maxValue , final Promise < Void > promise ) { if ( value == null ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + fieldName + "' has to be defined." ) ) ; } else if ( minValue != null && value . doubleValue ( ) < minValue . doubleValue ( ) ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + value + "' is not valid because it is less than '" + minValue + "'." ) ) ; } else if ( maxValue != null && value . doubleValue ( ) > maxValue . doubleValue ( ) ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + value + "' is not valid because it is greater than '" + maxValue + "'." ) ) ; } }
Validate that a number value is on the specified range.
Validate that a number value is on the specified range .