Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.