microsoft / PSRule

Validate infrastructure as code (IaC) and objects using PowerShell rules.

Home Page:https://microsoft.github.io/PSRule/v2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Realign expressions and assertion methods

BernieWhite opened this issue · comments

Discussed in #904

Originally posted by BernieWhite January 7, 2022
Across expressions (used in YAML and JSON resources) and assertion methods (used in PowerShell resources) there are different names used to equivalent functionality. While terminology differs between programming/ scripting languages we want to make it even easier to understand and author rules.

We should look to realign naming to be ideally the same for expressions and assertion methods.

This discussion proposes the following naming changes.

Expression Assertion method Proposed change
Contains Contains No change
Count Count No change
Equals n/a See note (1)
EndsWith EndsWith No change
Exists HasField Rename assertion method to Exists.
Greater Greater No change
GreaterOrEquals GreaterOrEqual Rename expression to GreaterOrEqual.
HasDefault HasDefaultValue Rename assertion method to HasDefault.
HasSchema HasJsonSchema Rename assertion method to HasSchema.
HasValue n/a See note (1).
In In No change
IsLower IsLower No change
IsString IsString No change
IsUpper IsUpper No change
Less Less No change
LessOrEquals LessOrEqual Rename expression to LessOrEqual.
Match Match No change
NotEquals n/a No change
NotIn NotIn No change
NotMatch NotMatch No change
SetOf SetOf No change
StartsWith StartsWith No change
Subset Subset No change
Version Version No change
n/a FileHeader No change
n/a FilePath No change
n/a HasFields No change
n/a HasFieldValue See note (1)
IsArray IsArray See note (2)
IsBoolean IsBoolean See note (2)
IsDateTime IsDateTime See note (2)
IsInteger IsInteger See note (2)
IsNumeric IsNumeric See note (2)
n/a JsonSchema No change
n/a NotHasField No change
n/a NotNull No change
NotWithinPath NotWithinPath See note (3)
n/a Null No change
n/a NullOrEmpty No change
n/a TypeOf No change
WithinPath WithinPath See note (3)
  • (1) The Equals, HasValue and expression and HasFieldValue are approximate. Also these are not necessarily intuitive.
    • It may be better to introduce Empty, NotEmpty, and Equal across expressions and assertion methods. Then deprecate Equals, HasValue and HasFieldValue.
  • (2) Added in #908.
  • (3) Added in #933.

https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Expressions/#hasvalue
https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Expressions/#equals
https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_Assert/#hasfieldvalue