model/src/main/java/eu/internetofus/common/model/ValidateContext.java
/**
   * Verify a field value is a non {@code null} or an empty string.
   *
   * @param fieldName name of the checking field.
   * @param value     to verify.
   * @param promise   to notify of any error.
   *
   * @return the normalized string value.
   */
Verify a field value is a non  null or an empty string.
@param fieldName name of the checking field.
@param value     to verify.
@param promise   to notify of any error.

@return the normalized string value.
Verify a field value is a non null or an empty string . @param fieldName name of the checking field . @param value to verify . @param promise to notify of any error . @return the normalized string value .
default String validateStringField(final String fieldName, final String value, final Promise<Void> promise) {
    if (value == null) {
      promise.tryFail(
          new ValidationErrorException(this.fieldErrorCode(fieldName), "The '" + fieldName + "' can not be 'null'."));
      return value;
    } else {
      final var trimmedValue = value.trim();
      if (trimmedValue.length() == 0) {
        promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName),
            "The '" + fieldName + "' can not be an empty value."));
        return value;
      } else {
        return trimmedValue;
      }
    }
  }
default String validateStringField ( final String fieldName , final String value , final Promise < Void > promise ) { if ( value == null ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + fieldName + "' can not be 'null'." ) ) ; return value ; } else { final var trimmedValue = value . trim ( ) ; if ( trimmedValue . length ( ) == 0 ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + fieldName + "' can not be an empty value." ) ) ; return value ; } else { return trimmedValue ; } } }
Verify a field value is a non {@code null} or an empty string.
Verify a field value is a non { @code null } or an empty string .