Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Powershell verb to indicate Validation?

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 .

like image 536
AnneTheAgile Avatar asked Jun 02 '15 17:06

AnneTheAgile


People also ask

How do I validate a PowerShell script?

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.

What are Verbs in PowerShell?

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.

What does get verb do in PowerShell?

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.

What naming convention do PowerShell cmdlets adopt that makes them easy to learn?

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.


1 Answers

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.
like image 88
Ansgar Wiechers Avatar answered Oct 13 '22 22:10

Ansgar Wiechers