Module cargo_lambda_interactive::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.
Macros
Shorthand for the built-in
ExactLengthValidator
that checks whether the answer length is
equal to the specified value.Shorthand for the built-in
MaxLengthValidator
that checks whether the answer length is
smaller than or equal to the specified threshold.Shorthand for the built-in
MinLengthValidator
that checks whether the answer length is
larger than or equal to the specified threshold.Shorthand for the built-in
ValueRequiredValidator
that checks whether the answer is not
empty.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
Validator used in
CustomType
prompts.Custom trait to call correct method to retrieve input length.
Validator used in
MultiSelect
prompts.