console-rs / dialoguer

Rust utility library for nice command line prompts and similar things
MIT License
1.3k stars 144 forks source link

Input validation #11

Closed batisteo closed 1 year ago

batisteo commented 5 years ago

It would be nice to have something similar:

https://github.com/CITGuru/PyInquirer/#input---type-input

nicohman commented 5 years ago

I added some basic input validation functionality, including prebuilt phone number and email address validators. Are there any other validators that you think should be in by default?

jamesmcm commented 4 years ago

Would it be possible to disallow the user to even enter characters for example?

So like we could set an Input to be numeric only, and pressing non-digits has no effect?

I haven't checked the source code to see if you handle it as a line of input or character by character, so this might not be possible.

pksunkara commented 4 years ago

No, that needs changes in the interaction logic for prompts. You can either write one yourself or if it's something common like a number, then contribute it to the library.

RobWalt commented 1 year ago

@batisteo I don't know when it was added, but there exists an input validation feature now. If you have some spare time, can you check if this is what you originally envisioned when you opened the issue?

batisteo commented 1 year ago

I guess it would do it. I was thinking about including some common ones (int, str, email…) but I far as I can see it seems very flexible solution.