Skip to content

Commit

Permalink
Fix fields null check in powershell model template (#8323)
Browse files Browse the repository at this point in the history
If field is boolean, the value might be $False.
The current null checking does not allow $False to be set.
  • Loading branch information
dordadush authored Jan 5, 2021
1 parent a9c168c commit 4cdf610
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function Initialize-{{{apiNamePrefix}}}{{{classname}}} {
{{#vars}}
{{^isNullable}}
{{#required}}
if (!${{{name}}}) {
if (${{{name}}} -eq $null) {
throw "invalid value for '{{{name}}}', '{{{name}}}' cannot be null."
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ function Initialize-PSPet {
'Creating PSCustomObject: PSPetstore => PSPet' | Write-Debug
$PSBoundParameters | Out-DebugParameter | Write-Debug

if (!$Name) {
if ($Name -eq $null) {
throw "invalid value for 'Name', 'Name' cannot be null."
}

if (!$PhotoUrls) {
if ($PhotoUrls -eq $null) {
throw "invalid value for 'PhotoUrls', 'PhotoUrls' cannot be null."
}

Expand Down

0 comments on commit 4cdf610

Please sign in to comment.