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

@return the normalized email value.
Verify a field value is null or a valid email address . @param fieldName name of the checking field . @param value to verify . @param promise to notify of any error . @return the normalized email value .
default String validateNullableEmailField(final String fieldName, final String value, final Promise<Void> promise) {
    if (value != null) {
      final var trimmedValue = value.trim();
      if (trimmedValue.length() > 0) {
        if (!EmailValidator.getInstance().isValid(trimmedValue)) {
          promise.tryFail(new ValidationErrorException(this.fieldErrorCode(fieldName),
              "The '" + trimmedValue + "' is not a valid e-mail address."));
          return value;
        } else {
          return trimmedValue;
        }
      }
    }
    return null;
  }
default String validateNullableEmailField ( final String fieldName , final String value , final Promise < Void > promise ) { if ( value != null ) { final var trimmedValue = value . trim ( ) ; if ( trimmedValue . length ( ) > 0 ) { if ( ! EmailValidator . getInstance ( ) . isValid ( trimmedValue ) ) { promise . tryFail ( new ValidationErrorException ( this . fieldErrorCode ( fieldName ) , "The '" + trimmedValue + "' is not a valid e-mail address." ) ) ; return value ; } else { return trimmedValue ; } } } return null ; }
Verify a field value is {@code null} or a valid email address.
Verify a field value is { @code null } or a valid email address .