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

@return the normalized list value.
Verify a field value is null or a list of strings . @param fieldName name of the checking field . @param value to verify . @param promise to notify of any error . @return the normalized list value .
default List<String> validateNullableStringListField(final String fieldName, final List<String> value,
      final Promise<Void> promise) {
    if (value != null) {
      final var validValues = new ArrayList<String>();
      final var max = value.size();
      for (var index = 0; index < max; index++) {
        final var element = this.normalizeString(value.get(index));
        if (element != null) {
          final var found = validValues.indexOf(element);
          if (found > -1) {
            promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName) + "[" + index + "]",
                "'" + element + "' is duplicated at '" + found + "'."));
            return value;
          }
          validValues.add(element);
        }
      }
      return validValues;
    }
    return null;
  }
default List < String > validateNullableStringListField ( final String fieldName , final List < String > value , final Promise < Void > promise ) { if ( value != null ) { final var validValues = new ArrayList < String > ( ) ; final var max = value . size ( ) ; for ( var index = 0 ; index < max ; index ++ ) { final var element = this . normalizeString ( value . get ( index ) ) ; if ( element != null ) { final var found = validValues . indexOf ( element ) ; if ( found > - 1 ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) + "[" + index + "]" , "'" + element + "' is duplicated at '" + found + "'." ) ) ; return value ; } validValues . add ( element ) ; } } return validValues ; } return null ; }
Verify a field value is {@code null} or a list of strings.
Verify a field value is { @code null } or a list of strings .