I often have a method that validates a particular value. In powershell, the convention is to use a verb within the 'get-verb' list, but I am puzzled on which one would be best for this usage.
Alternatively, if my design architecture should change to avoid validation through a method in some other manner I would welcome suggestions along that line too.
Verbs that are roughly related are: Ensure, Compare, Edit, Convert, Initialize, Update, Assert, Confirm, Measure, Resolve, Test, Write, Grant , Use .
It can be added inside the parameter definition block of a function, or it can also be used directly in the PowerShell console. ValidateScript is used to validate the value of the parameter you entered. If the validation result is $true , then the script will continue to run.
PowerShell uses a verb-noun pair for the names of cmdlets and for their derived . NET classes. The verb part of the name identifies the action that the cmdlet performs. The noun part of the name identifies the entity on which the action is performed.
Description. The Get-Verb function gets verbs that are approved for use in PowerShell commands. PowerShell recommends cmdlet and function names have the Verb-Noun format and include an approved verb. This practice makes command names more consistent, predictable, and easier to use.
Windows PowerShell prefers the singular form of nouns. It is not a design requirement, but it is a strong preference. Therefore, the cmdlets are named Get-Service, Get-Process, and not Get-Services or Get-Processes.
The appropriate verb for validating a value is Test
. Quoting from the Approved Verbs list (section Diagnostic Verbs):
Verb (alias) Action Comments ... ... ... Test (t) Verifies the operation or For this action, do not use verbs consistency of a resource. such as Diagnose, Analyze, Salvage, or Verify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With