Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrictors #3784

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Restrictors #3784

wants to merge 7 commits into from

Conversation

burbma
Copy link

@burbma burbma commented Nov 30, 2023

I have a use case where I'd like essentially the same functionality as validators but in a restriction sense. The main difference I'm after is that rather than setting an invalid flag and thus giving the user visual and textual feedback, I'd like the text to just not show up. I've been using Textual for about 6 hours so if I'm way off base here in my solution I won't take offense. As I was writing the tests I came across the Function validator and thought that the existing restrict capabilities like type, max_length, and the restrict regex could probably be Restrictors and the Restrictor I wrote could be the Function restrictor, mirroring the validation pattern. I haven't implemented that latter part here but rather just a Restrictor class that essentially acts as a hybrid of the Function validator (in that you can define your own arbitrary predicate) and restrict regex (in that the text simply doesn't show up in the Input).

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Existing tests pass
  • New tests pass
  • Updated CHANGELOG.md (where appropriate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant