Skip to main content

Module validate

Module validate 

Source
Expand description

Answer validation with interactive re-ask.

A Validator inspects a candidate answer and either accepts it or returns a short human-readable reason. In an interactive prompt the reason is shown and the question is re-asked; in PromptMode::NonInteractive a rejected default is a typed error rather than a silent bad value.

Any Fn(&str) -> Result<(), String> is a Validator, so callers pass a closure directly; reusable rules can also implement the trait by hand.

Traits§

Validator
Inspects a candidate answer, accepting it or explaining why it is rejected.

Functions§

non_empty
A validator that rejects empty or whitespace-only input with message.

Type Aliases§

Validation
The outcome of validating a candidate answer: Ok(()) accepts it, Err carries a short reason to display before re-asking.