Enhance ValidateRange attributes
See original GitHub issueFrom https://github.com/PowerShell/PowerShell/pull/4084#issuecomment-312478357
We could enhance and unify Ranges. Currently Min and Max values are allowed but user can want to exclude them. Ex., “Positive” exclude zero. So the “Positive” range looks:
ValidateRange(0, int.MaxValue, RangeOption.ExcludeMin)
“Negative”:
ValidateRange( -int.MaxValue, 0, RangeOption.ExcludeMax)
Exclude both (allow 0.5):
ValidateRange( 0, 1, RangeOption.ExcludeMin+RangeOption.ExcludeMax)
And we can move switch (rangeKind)
to a constructor (with assigning a specific error message) and implement general ValidateElement method.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
ValidateRange Attribute Declaration - PowerShell
The ValidateRange attribute specifies the minimum and maximum values (the range) for the cmdlet parameter argument. This attribute can also ...
Read more >How to use the ValidateRange attribute in PowerShell ...
ValidateRange Attribute. This parameter is to validate the specific range of numbers. For example, If we need users to enter a value between...
Read more >How can ensure that a function only accepts a positive ...
The ValidateRange attribute specifies a numeric range or a ValidateRangeKind enum value for each parameter or variable value. PowerShell ...
Read more >How to use the ValidateSet Attribute in PowerShell function
The ValidateSet attribute in PowerShell function is to validate the values entered from the set which means, it allows only specific values ...
Read more >Validate number ranges - ScriptRunner Documentation
ValidateRange attribute. Use any input field combined with the ValidateRange parameter attribute to create an input field that expects a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yes @iSazonov , please assign to me
It’s also very subjective. It also gives rise to complexity if it falls short of our expectations. You like Positive/Negative. I would preffer classic math terms: (a, b) (a, b] [a, b) [a, b]