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§
- Exact
Length Validator - Built-in validator that checks whether the answer length is equal to the specified value.
- MaxLength
Validator - Built-in validator that checks whether the answer length is smaller than or equal to the specified threshold.
- MinLength
Validator - Built-in validator that checks whether the answer length is larger than or equal to the specified threshold.
- Value
Required Validator - Built-in validator that checks whether the answer is not empty.
Enums§
- Error
Message - Error message that is displayed to the users when their input is considered not valid by registered validators.
- Validation
- The result type of validation operations when the execution of the validator function succeeds.
Traits§
- Custom
Type Validator - Validator used in
CustomType
prompts. - Inquire
Length - Custom trait to call correct method to retrieve input length.
- Multi
Option Validator - Validator used in
MultiSelect
prompts. - String
Validator - Validator that receives a string slice as the input, such as
Text
andPassword
.