Private/Test-KadenBetaInvitation.ps1

function Test-KadenBetaInvitation {
    <#
    .SYNOPSIS
        Accept a six-word beta invitation that ends with the literal word Beta.
    .DESCRIPTION
        The first five words must come from the curated list. This is a cohort signal only. It does not enforce use, confidentiality, licensing, or authorization.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [AllowEmptyString()]
        [string]$Invitation
    )

    $parts = @($Invitation -split '\s+' | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
    if ($parts.Count -ne 6) {
        return [pscustomobject]@{
            Valid   = $false
            Message = 'KDN-BETA-INVITATION-INVALID: Beta invitation must be six words: five curated words followed by Beta.'
        }
    }
    if ($parts[-1] -cne 'Beta') {
        return [pscustomobject]@{
            Valid   = $false
            Message = 'KDN-BETA-INVITATION-INVALID: Beta invitation must end with the literal word Beta.'
        }
    }

    $allowed = @(Get-KadenInvitationWordList)
    for ($i = 0; $i -lt 5; $i++) {
        if ($allowed -notcontains $parts[$i]) {
            return [pscustomobject]@{
                Valid   = $false
                Message = 'KDN-BETA-INVITATION-INVALID: Beta invitation must use five curated words followed by Beta.'
            }
        }
    }

    return [pscustomobject]@{
        Valid   = $true
        Message = 'Beta acknowledgement accepted. The invitation is a shareable feedback-cohort signal; it is bypassable and does not enforce use, confidentiality, licensing, or authorization.'
    }
}