Bug in input handling?

I have an input field and I want to allow users to leave it blank. I expected that the value of the variable to be $null when I validated it, but it wasn’t. Then I expected it to be an empty string "", but it was sometimes and not other times, quite confusingly. Apparently, the code below returns a string with the text value of “null” if the field has never been touched, but if it was typed into and then deleted before submitting, it returns a value of an empty string "". At the very least, this inconsistent behavior is a bug, I think, but honestly, I wish, regardless, they returned with a value of $null. Thoughts?

$Content = {New-UDDashboard -Content {
    New-UDInput -Title "Output Options" -SubmitText "Search!" -Content {
        New-UDInputField -Name AdditionalEmail -Type textbox -Placeholder "List of additional email addresses to send to."
    } -Endpoint {
        param($AdditionalEmail)
        if ($AdditionalEmail -eq $null) {New-UDInputAction -Toast "The value of Additional Email is: `$null" -Duration 5000}
        else {New-UDInputAction -Toast "Additional Email is of type: $($AdditionalEmail.gettype())" -Duration 5000}
        if ($AdditionalEmail -eq "") {New-UDInputAction -Toast "The value of Additional Email is: Empty String" -Duration 5000}
        if ($AdditionalEmail -eq "null") {New-UDInputAction -Toast "The value of Additional Email is: `"null`"" -Duration 5000}
    }
}}
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Content $Content -Port 10000

I’ve had the same issue so I set the -DefaultValue of all string fields to “”. That way handling content is the same either way.
My guess is there’s a typo of null instead of $null in the code. UD v3 will fix everything.

gav

Thanks for the tip! I hadn’t thought about that. I had just added this one line at the beginning of my validation -Endpoint block and it has worked well for me.

if ($AdditionalEmail -eq "null" -or $AdditionalEmail -eq "") {$AdditionalEmail = $null}