Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

Validate all arguments together #178

Open
2 tasks done
epage opened this issue Dec 6, 2021 · 0 comments
Open
2 tasks done

Validate all arguments together #178

epage opened this issue Dec 6, 2021 · 0 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by giggio
Saturday Feb 06, 2021 at 22:12 GMT
Originally opened as clap-rs/clap#2332


Make sure you completed the following tasks

Describe your use case

I'd like to have a validation function that would validate the arguments together.

Describe the solution you'd like

I'm thinking something like this:

App::new("x")
    .validate(|args| /* some logic and... */ Err(("myarg", "Why invalid"));

(I'm not married to this example, it is just so we can have an idea)

In this case, argument myarg is invalid, after I've gone through some logic that would go through all arguments already supplied (and validated individually).

Alternatives, if applicable

Validate after parsing using ArgMatches.

Additional context

Already discussed at #1913 and #1206, and I think a solution with a closure after on the app context could make sense.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant