Skip to content

Commit

Permalink
Merge pull request PowershellFrameworkCollective#611 from nyanhp/guid…
Browse files Browse the repository at this point in the history
…validator

Add single GUID validator
  • Loading branch information
FriedrichWeinmann authored Jan 10, 2024
2 parents a19bbc2 + e3f43c4 commit f394b04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PSFramework/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Unreleased

- New: Configuration Validation: guid - ensures only legal guids can be added

## 1.10.318 (2023-11-10)

- New: Component: Runspace Workflows - architect parallelized workflows without having to deal with the details of runspaces.
Expand Down
23 changes: 23 additions & 0 deletions PSFramework/internal/configurationvalidation/guid.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Register-PSFConfigValidation -Name "guid" -ScriptBlock {
Param (
$Value
)

$Result = [PSCustomObject]@{
Success = $True
Value = $null
Message = ""
}

try { [guid]$guid = $Value }
catch
{
$Result.Message = "Not a GUID: $Value"
$Result.Success = $False
return $Result
}

$Result.Value = $guid

return $Result
}

0 comments on commit f394b04

Please sign in to comment.