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

How to add constraints to an int option? #905

Open
loudenvier opened this issue Nov 2, 2023 · 0 comments
Open

How to add constraints to an int option? #905

loudenvier opened this issue Nov 2, 2023 · 0 comments

Comments

@loudenvier
Copy link

Is it possible to set constraints to an int option so that it have min and max allowed values? I think that's a pretty common scenario, but the following fails:

[Option('q', "quality", Default = 80, Min = 1, Max = 100)]
public int Quality { get; set; }    

With this exception: System.InvalidOperationException: Scalar option specifications do not support range specification.

If the library does not provide this functionality how would I implement it on my own and still play nicely with the auto help and error messages that the library automatically outputs on invalid input?

@loudenvier loudenvier changed the title How to validate an int option? How to add constraints to an int option? Nov 2, 2023
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

No branches or pull requests

1 participant