Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate after parsing #42

Closed
wants to merge 1 commit into from

Conversation

vallentin
Copy link
Contributor

@vallentin vallentin commented Feb 3, 2020

Simply swapped around parsing and validating. If it successfully parses, then validate. Since if parsing fails, then it doesn't matter if it was validated.

Example:

Input::<i32>::new()
    .validate_with(|_input: &str| -> Result<(), &str> {
        println!("Validate");
        Ok(())
    })
    .interact()
    .unwrap();

Before if you entered foo, then it would display:

Validate
error: invalid digit found in string

This was referenced Feb 4, 2020
@pksunkara
Copy link
Collaborator

Cherry picked this.

@pksunkara pksunkara closed this Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants