Created
June 12, 2019 18:57
-
-
Save chriskuech/f51051d0b55a3c15ff171756a01c9253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-Requirement { | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[ValidateNotNullOrEmpty()] | |
[Requirement[]]$Requirement | |
) | |
process { | |
$result = &$_.Test | |
if (-not $result) { | |
&$_.Set | Out-Null | |
$result = &$_.Test | |
if (-not $result) { | |
throw "Validation failed for '$($_.Name)'" | |
} | |
} | |
} | |
} | |
$requirements | Invoke-Requirement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment