-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature: Add support for validation functions #1785
Conversation
Add new fv Fix more tests Add validator Add sample validation functions Revert some changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I really like this capability
- I'm super nervous about depending on golang.org/x/exp
- I don't like the alternatives to depending on golang.org/x/exp
- I'm nervous about how much this expands the API surface area
What do you think about making some/most of this an "addon" library like with urfave/cli-docs and urfave/cli-altsrc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aww, I liked the validation helper bits! 😭 WDYT about renaming urfave/cli-altsrc
to urfave/cli-ext
and including them over there?
Hmm thats not a bad idea at all. I'm ok with that. cli-docs would go in there as well ? Would you like to take point on that ? |
|
Hmm thats not a bad idea at all. I'm ok with that. cli-docs would go in there as well ? Would you like to take point on that ? |
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This PR adds a framework for allowing users to be able to define custom validators on flags. Some very basic rudimentary ones have been provided for demonstration purposes to be able to gather user feedback on easy of use. Other validation functions may be provided in the future if users requests common ones. Note that the validation happens in the same context as when the value is set from the command line so slice flag validations for length may not work as expected.
Which issue(s) this PR fixes:
(REQUIRED)
Special notes for your reviewer:
(fill-in or delete this section)
Testing
(fill-in or delete this section)
Add new validation test cases,
Release Notes
(REQUIRED)