public ComponentValidator andRegisterOnDocumentListener(@NotNull JTextComponent textComponent) {
    DocumentAdapter listener = new DocumentAdapter() {
      @Override
      protected void textChanged(@NotNull DocumentEvent e) {
        getInstance(textComponent).ifPresent(ComponentValidator::revalidate); // Don't use 'this' to avoid cyclic references.
      }
    };
    textComponent.getDocument().addDocumentListener(listener);
    Disposer.register(parentDisposable, () -> {
      textComponent.getDocument().removeDocumentListener(listener);
    });
    return this;
  }
public ComponentValidator andRegisterOnDocumentListener(@NotNull JTextComponent textComponent)