Title: Error is wrong when value given for IValidateSetValuesGenerator is not in GetValidValues() · Issue #4698 · PowerShell/PowerShell · GitHub
Open Graph Title: Error is wrong when value given for IValidateSetValuesGenerator is not in GetValidValues() · Issue #4698 · PowerShell/PowerShell
X Title: Error is wrong when value given for IValidateSetValuesGenerator is not in GetValidValues() · Issue #4698 · PowerShell/PowerShell
Description: Steps to reproduce class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator { [string[]] GetValidValues() { return 'Hello', 'World' } } function Test-ValidateSet { [CmdletBinding()] param ( [Parameter(Mandatory = ...
Open Graph Description: Steps to reproduce class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator { [string[]] GetValidValues() { return 'Hello', 'World' } } function Test-ValidateSet { [CmdletBi...
X Description: Steps to reproduce class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator { [string[]] GetValidValues() { return 'Hello', 'World' } } function Test-Validat...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4698
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error is wrong when value given for IValidateSetValuesGenerator is not in GetValidValues()","articleBody":"Steps to reproduce\r\n------------------\r\n\r\n```powershell\r\nclass ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator\r\n{\r\n [string[]] GetValidValues()\r\n {\r\n return 'Hello', 'World'\r\n }\r\n}\r\n\r\nfunction Test-ValidateSet\r\n{\r\n [CmdletBinding()]\r\n param (\r\n [Parameter(Mandatory = $true)]\r\n [ValidateSet([ValidateSetTest])]\r\n [string[]]\r\n $Item\r\n )\r\n $Item\r\n}\r\n\r\nTest-ValidateSet -Item 'Cheese'\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n```none\r\nTest-ValidateSet : Cannot validate argument on parameter 'Item'. The argument \"Cheese\" does not belong to the set\r\n\"Hello,World\" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command\r\nagain.\r\nAt line:1 char:24\r\n+ Test-ValidateSet -Item 'Cheese'\r\n+ ~~~~~~~\r\n + CategoryInfo : InvalidData: (:) [Test-ValidateSet], ParameterBindingValidationException\r\n + FullyQualifiedErrorId : ParameterArgumentValidationError,Test-ValidateSet\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\nTest-ValidateSet : Cannot validate argument on parameter 'Item'. Value cannot be null.\r\nParameter name: value\r\nAt line:1 char:24\r\n+ Test-ValidateSet -Item 'Cheese'\r\n+ ~~~~~~~~\r\n + CategoryInfo : InvalidData: (:) [Test-ValidateSet], ParameterBindingValidationException\r\n + FullyQualifiedErrorId : ParameterArgumentValidationError,Test-ValidateSet\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```powershell\r\nName Value\r\n---- -----\r\nPSVersion 6.0.0-beta\r\nPSEdition Core\r\nGitCommitId v6.0.0-beta.6\r\nOS Microsoft Windows 10.0.15063\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/lfshr","@type":"Person","name":"lfshr"},"datePublished":"2017-08-29T14:12:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/4698/PowerShell/issues/4698"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0a0e1956-d336-b656-2fde-da1640e50d20 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B370:2B362A:6F456B:977AED:6A57D5AF |
| html-safe-nonce | 78d95f825ffdc539d222a52b25a5831062218498561c820e1e9e7b8097a729ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzcwOjJCMzYyQTo2RjQ1NkI6OTc3QUVEOjZBNTdENUFGIiwidmlzaXRvcl9pZCI6IjQ5MDkwOTQ2MzQxMDA2MTA0NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 88417b575dad8fa54bdebfea997370218a0a85f317b9b22addc7b727020d44ba |
| hovercard-subject-tag | issue:253676967 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/4698/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa233f18462dacad8d8f9ea05b36216b223403fe3e97f73f3cc3eef652cb975c/PowerShell/PowerShell/issues/4698 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa233f18462dacad8d8f9ea05b36216b223403fe3e97f73f3cc3eef652cb975c/PowerShell/PowerShell/issues/4698 |
| og:image:alt | Steps to reproduce class ValidateSetTest : System.Management.Automation.IValidateSetValuesGenerator { [string[]] GetValidValues() { return 'Hello', 'World' } } function Test-ValidateSet { [CmdletBi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lfshr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 837767abbd14b05f219fd812ef2842c659968b63619e1b966dded83972ab5bca |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9044d0f867aa9892268d1f430238ff123e11ee91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width