Skip to main content

prompt_text_with_validation

Function prompt_text_with_validation 

Source
pub fn prompt_text_with_validation(
    message: &str,
    default: Option<&str>,
    validator: impl Fn(&str) -> Result<(), String> + Clone + 'static,
) -> Result<String>
Expand description

Prompt the user for a free-text string with input validation.

The validator closure should return Ok(()) if the input is valid, or Err(message) with a user-facing explanation if invalid.

ยงErrors

Returns CliCoreError if the prompt is cancelled or a terminal error occurs.