dotnet / dotnet/command-line-api
`Command.Validators` should be invoked only when the command options are arguments are valid
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
For `Option` and `Argument`, custom validators are invoked before the conversion from the token (`string`) to `T`. It's well behavior for the use case such the production of better error messages, even so the behavior is not well documented (related #2645).
For `Command`, as same as above, validators are invoked before its options and arguments today, but it's useless.
I expect to be able to use `Command` validators for the **complex validation** of our command line. In other words, the options and arguments should be validated with their definitions (`Arity`, `AllowMultipleArgumentsPerToken`, `CustomParser`, etc, and `Validators`) first, then only when no one have any errors, the command validators should be invoked.
Or, reading the values of options and arguments from `Command.Validators` is incorrect? If so, better documentation is needed.
Contributor guide
Assessment
This issue has not been assessed yet.