Module inquire::validator

source ·
Expand description

Traits and structs used by prompts to validate user input before returning the values to their callers.

Validators receive the user input to a given prompt and decide whether they are valid, returning Ok(Validation::Valid) in the process, or invalid, returning Ok(Validation::Invalid(ErrorMessage)), where the ErrorMessage content is an error message to be displayed to the end user.

Validators can also return errors, which propagate to the caller prompt and cause the prompt to return the error.

This module also provides several macros as shorthands to the struct constructor functions, exported with the macros feature.

Structs§

  • Built-in validator that checks whether the answer length is equal to the specified value.
  • Built-in validator that checks whether the answer length is smaller than or equal to the specified threshold.
  • Built-in validator that checks whether the answer length is larger than or equal to the specified threshold.
  • Built-in validator that checks whether the answer is not empty.

Enums§

  • Error message that is displayed to the users when their input is considered not valid by registered validators.
  • The result type of validation operations when the execution of the validator function succeeds.

Traits§