1use dialoguer_ext::{theme::ColorfulTheme, Password};
2
3fn main() {
4 let password = Password::with_theme(&ColorfulTheme::default())
5 .with_prompt("Password")
6 .with_confirmation("Repeat password", "Error: the passwords don't match.")
7 .validate_with(|input: &String| -> Result<(), &str> {
8 if input.chars().count() > 3 {
9 Ok(())
10 } else {
11 Err("Password must be longer than 3")
12 }
13 })
14 .interact()
15 .unwrap();
16
17 println!(
18 "Your password is {} characters long",
19 password.chars().count()
20 );
21}