Skip to content

Commit

Permalink
new parameter binding test
Browse files Browse the repository at this point in the history
  • Loading branch information
ninmonkey committed Dec 5, 2023
1 parent dd43e77 commit 6f5efce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Pwsh/Parameters/Using-ThrowIfNullOrWhiteSpace-OnObjects.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function FormatDate {
param(
[Parameter(Mandatory, ValueFromPipeline)]
[datetime]$Dt,

[Parameter()]
[ArgumentCompletions(
'([CultureInfo]::InvariantCulture)', 'en-us', 'de-de' )]
[CultureInfo]$Culture = ([CultureInfo]::InvariantCulture)
)

$null -eq $Culture | Join-String -f 'Cult == $Null: ' | write-verbose -verb
if( [String]::IsNullOrWhiteSpace( $Culture )) {
throw "MandatoryCultureWasBlank!"
}
[ArgumentException]::ThrowIfNullOrWhiteSpace( $Culture, 'Culture' )
}
return


# FormatDate (Get-Date)
# (get-date).ToString( [cultureinfo]::InvariantCulture )
# Get-Date | FormatDate -Culture ([CultureInfo]::InvariantCulture)

0 comments on commit 6f5efce

Please sign in to comment.