pub struct ValueRequiredValidator { /* private fields */ }
Expand description

Built-in validator that checks whether the answer is not empty.

Examples

use inquire::validator::{StringValidator, Validation, ValueRequiredValidator};

let validator = ValueRequiredValidator::default();
assert_eq!(Validation::Valid, validator.validate("Generic input")?);
assert_eq!(Validation::Invalid("A response is required.".into()), validator.validate("")?);

let validator = ValueRequiredValidator::new("No empty!");
assert_eq!(Validation::Valid, validator.validate("Generic input")?);
assert_eq!(Validation::Invalid("No empty!".into()), validator.validate("")?);

Implementations§

Create a new instance of this validator with given error message.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Create a new instance of this validator with the default error message A response is required.

Confirm the given input string is a valid value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.