question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhance ValidateRange attributes

See original GitHub issue

From 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:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dchristian3188commented, Aug 3, 2017

yes @iSazonov , please assign to me

0reactions
iSazonovcommented, Aug 9, 2017

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]

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found