Functions/Public/Assert-RequiredObjectProperty.ps1

function Assert-RequiredObjectProperty {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [ValidateNotNull()]
        [Array] $requiredProperties,

        [Parameter(Mandatory = $true)]
        [ValidateNotNull()]
        [Object] $object
    )
    foreach ($propertyNm in $requiredProperties) {
        $propertyValue = $object[$propertyNm]
        if ($null -eq $propertyValue -or "" -eq $propertyValue.ToString()) {
            Throw [System.Management.Automation.ValidationMetadataException] `
                "Required object property '$propertyNm' has either a NULL or empty value"
        }
    }
}

class ValidateRequiredObjectPropertiesAttribute : System.Management.Automation.ValidateArgumentsAttribute {
    [Array] $RequiredProperties = @()

    ValidateRequiredObjectPropertiesAttribute([Array] $RequiredProperties) {
        $this.RequiredProperties = $RequiredProperties;
    }

    [void] Validate([object] $Arguments, [System.Management.Automation.EngineIntrinsics] $EngineIntrinsics) {
        Assert-ObjectProperty -requiredProperties $this.RequiredProperties -object $Arguments
    }
}
# SIG # Begin signature block
# MIIaxQYJKoZIhvcNAQcCoIIatjCCGrICAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDvjbwasmipNLQT
# JTA0gzs1Zd/YLWiTadqrgYFUvCMtg6CCCqMwggUwMIIEGKADAgECAhAECRgbX9W7
# ZnVTQ7VvlVAIMA0GCSqGSIb3DQEBCwUAMGUxCzAJBgNVBAYTAlVTMRUwEwYDVQQK
# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xJDAiBgNV
# BAMTG0RpZ2lDZXJ0IEFzc3VyZWQgSUQgUm9vdCBDQTAeFw0xMzEwMjIxMjAwMDBa
# Fw0yODEwMjIxMjAwMDBaMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2Vy
#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