prompt-toolkit / prompt-toolkit/python-prompt-toolkit

how to implement a custom validator for a custom TokenListControl

Open
#430 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

I am writing a custom checkbox widget based on prompt-toolkit. So far it works great. Now I want to add a validator so I can validate that for example at least one checkbox has been selected.
I understand that prompt-toolkit validators work on a Document which in turn is part of a Buffer. A TokenListControl has none of that. I could raise a ValidationError from my validator which runs in own scope - so it does not help much...
Any suggestions on how to best approach this? Are there any hooks I can use, do I use a bottom_toolbar (additional TokenListControl) to implement the validation message display myself?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how TokenListControl differs from the Document and Buffer validation path, and review the suggested bottom_toolbar approach for displaying feedback. Done means identifying and documenting a supported hook or a clear validation-message pattern for custom checkbox controls.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.