<commit_before>﻿param(
[Parameter(Mandatory=$true,Position=0)]
[PSObject]
$CreateUIDefinitionObject
)

# First, check that CreateUIDefinition has an outputs
if (-not $CreateUIDefinitionObject.parameters.outputs) {
    # (if it didn't, throw an error)
    throw "Outputs is missing from CreateUIDefinition"
    $CreateUIDefinitionObject.parameters.outputs | Out-String
}
if (-not $CreateUIDefinitionObject.parameters.outputs.location) {
    throw "Location is missing from outputs"
}

# Then, check that the location property exists in outputs
if (-not $CreateUIDefinitionObject.parameters.outputs.location) { 
    # (if it didn't, throw an error).
    throw "Location is missing from outputs"
}

# Last, make sure that the location's trimmed value is [location()]
if ("$($CreateUIDefinitionObject.outputs.location)".Trim() -ne '[location()]') {
    # (if it wasn't, throw an error)
    if ("$($CreateUIDefinitionObject.parameters.outputs.location)".Trim() -ne '[location()]') {
        throw "CreateUIDefinition.outputs.location must be [location()]"
    }
}<commit_msg>Removing Throws, Improving Documentation, Adding Good/Bad Input<commit_after>﻿<#
.Synopsis
    Ensures that the .location field exists in .outputs.
.Description
    Ensures that the .location field exists in .outputs, and is [location()]
.Example
    Test-AzureRMTemplate -TemplatePath .\100-marketplace-sample -Test Location-Should-Be-In-Outputs
.Example
    .\Location-Should-Be-In-Outputs.test.ps1 ([PSCustomObject]@{BadInput=$true})
#>
param(
[Parameter(Mandatory=$true,Position=0)]
[PSObject]
$CreateUIDefinitionObject
)
<#{
    Bad: {},
    Good: {
        parameters: {
            outputs: {
                location:"[location()]"
            }
        }
    }                
}#>


if (-not $CreateUIDefinitionObject.parameters.outputs) { # If CreateUIDefinition has no outputs
    Write-Error "Outputs is missing from CreateUIDefinition" -ErrorId CreateUIDefinition.Missing.Outputs # error
    return # and return.
}
if (-not $CreateUIDefinitionObject.parameters.outputs.location) { # If outputs does not have a location    
    Write-Error "Location is missing from outputs" -ErrorId CreateUIDefinition.Missing.Outputs.Location # error
    return # and return.
}

if ("$($CreateUIDefinitionObject.parameters.outputs.location)".Trim() -ne '[location()]') { # Last, make sure that the location's trimmed value is [location()].
    Write-Error "CreateUIDefinition.outputs.location must be [location()]" -ErrorId CreateUIDefinition.Incorrect.Outputs.Location -TargetObject $CreateUIDefinitionObject.parameters.outputs.location
}
{'fraction_non_alphanumeric': 0.12010744435917114, 'fraction_numerical': 0.0023023791250959325, 'mean_word_length': 4.1420118343195265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3755409', 'n_tokens_mistral': 763, 'n_tokens_neox': 748, 'n_words': 201}