src/Validator.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

function Confirm-Arguments {
    param(
        [string]$Site,
        [Alias('l')][Switch]$Lowercase,
        [Alias('nl')][Switch]$noLowercase,
        [Alias('u')][Switch]$Uppercase,
        [Alias('nu')][Switch]$noUppercase,
        [Alias('d')][Switch]$Digits,
        [Alias('nd')][Switch]$noDigits,
        [Alias('s')][Switch]$Symbols,
        [Alias('ns')][Switch]$noSymbols,
        [Switch]$Prompt,
        [Switch]$Clipboard
    )

    if ($PSBoundParameters.Lowercase -and $PSBoundParameters.noLowercase) {
        throw "* Can't have opposite rule -L (or -Lowercase) and -NL (or -No-Lowercase) at the same time."
    }
    if ($PSBoundParameters.Uppercase -and $PSBoundParameters.noUppercase) {
        throw "* Can't have opposite rule -U (or -Uppercase) and -NU (or -No-Uppercase) at the same time."
    }
    if ($PSBoundParameters.Digits -and $PSBoundParameters.noDigits) {
        throw "* Can't have opposite rule -D (or -Digits) and -ND (or -No-Digits) at the same time."
    }
    if ($PSBoundParameters.Symbols -and $PSBoundParameters.noSymbols) {
        throw "* Can't have opposite rule -S (or -Symbols) and -NS (or -No-Symbols) at the same time."
    }
    if (!$PSBoundParameters.Site -and !$PSBoundParameters.Prompt) {
        throw " * SITE is a required argument (unless in interactive mode with -Prompt)"
    }
    if ($PSBoundParameters.Clipboard) {
        Get-SystemCopyCommand
    }
}
Export-ModuleMember -Function Confirm-Arguments