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

@return the normalized date value.
Verify a field value is null or a valid date . @param fieldName name of the checking field . @param value to verify . @param format that has to have the date . @param promise to notify of any error . @return the normalized date value .
default String validateNullableDateField(final String fieldName, final String value, final DateTimeFormatter format,
      final Promise<Void> promise) {
    if (value != null) {
      final var trimmedValue = value.trim();
      if (trimmedValue.length() > 0) {
        try {
          final var date = format.parse(trimmedValue);
          return format.format(date);
        } catch (final Throwable badDate) {
          promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName), badDate));
          return value;
        }
      }
    }
    return null;
  }
default String validateNullableDateField ( final String fieldName , final String value , final DateTimeFormatter format , final Promise < Void > promise ) { if ( value != null ) { final var trimmedValue = value . trim ( ) ; if ( trimmedValue . length ( ) > 0 ) { try { final var date = format . parse ( trimmedValue ) ; return format . format ( date ) ; } catch ( final Throwable badDate ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , badDate ) ) ; return value ; } } } return null ; }
Verify a field value is {@code null} or a valid date.
Verify a field value is { @code null } or a valid date .