Consider posting in https://github.com/textualize/rich/discussions for feedback before raising a feature request.
Have you checked the issues for a similar suggestions? Yes. Have not found the request among open issues or PRs.
How would you improve Rich?
I would love to have a Prompt class that can validate string input based on a regex pattern :)
What problem does it solve for you?
It may be the fastest way to implement an string validated prompt.
** Code example **
Probably not the best example implementation but... :)
class RegexPrompt(PromptBase[str]):
response_type = str
def __init__(self, regex, validate_error_message, *kwargs):
super().__init__(kwargs)
self._regex = regex
self.validate_error_message = "[prompt.invalid]"+validate_error_message
def process_response(self, value: str) -> str:
if not self._regex.fullmatch(value):
raise InvalidResponse(self.validate_error_message)
return value
Consider posting in https://github.com/textualize/rich/discussions for feedback before raising a feature request.
Have you checked the issues for a similar suggestions? Yes. Have not found the request among open issues or PRs.
How would you improve Rich?
I would love to have a Prompt class that can validate string input based on a regex pattern :)
What problem does it solve for you?
It may be the fastest way to implement an string validated prompt.
** Code example **
Probably not the best example implementation but... :)