rio-labs / rio

WebApps in pure Python. No JavaScript, HTML and CSS needed
https://rio.dev
Apache License 2.0
1.36k stars 40 forks source link

`max_length` and `valid_inputs` Support for `rio.TextInput` #137

Open Sn3llius opened 1 month ago

Sn3llius commented 1 month ago

Description

Enhance the rio.TextInput component by adding support for two new features: max_length and valid_inputs. These features will provide greater control over the input data by restricting the length of the text and the valid characters or patterns users can input.

Suggested Solution

max_length should be pretty self explanatory. Should work analogue to . Default should be None

valid_inputs should take a string or Iterable[str], preventing other symbols for being put in. default should be string.printable

Alternatives

No response

Additional Context

No response

Related Issues/Pull Requests

No response

mad-moo commented 1 month ago

While I like the proposal in general, I'd argue for an alternate way of specifying what constitutes valid content - regex. This would allow for much more flexibility in what users can (and cannot!) enter.

This comes with challenges however, which is also the reason it doesn't exist yet:

This needs discussion.