Skip to content

Instantly share code, notes, and snippets.

@aetos382
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aetos382/b90d18c96ca0ed63e04d to your computer and use it in GitHub Desktop.
Save aetos382/b90d18c96ca0ed63e04d to your computer and use it in GitHub Desktop.
function Hoge
{
param(
[ValidateNotNullOrEmpty()]
[string[]] $x = @())
@($x) | % { ... }
}
$x = @()
<#
この辺で、$x に値を追加していく。
結果的に $x は空の場合もあるとする。
#>
# 空だとエラーになるので、判別しないといけない。
if ($x)
{
Hoge $x
}
else
{
Hoge
}
function Hoge
{
param(
[PSValidator.ValidateNotEmptyString()]
[string[]] $x = @())
@($x) | % { ... }
}
$x = @()
<#
この辺で、$x に値を追加していく。
結果的に $x は空の場合もあるとする。
#>
# 空でも大丈夫。
Hoge $x
function Hoge
{
param(
[ValidateLength(1, [int]::MaxValue)]
[string[]] $x = @())
@($x) | % { ... }
}
$x = @()
<#
この辺で、$x に値を追加していく。
結果的に $x は空の場合もあるとする。
#>
# 空でも大丈夫。
Hoge $x
function Hoge
{
param(
[ValidateScript({ Test-Path $_ })]
[string[]] $x = @())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment