mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
[PM-3326] [CLI] Add minNumber, minSpecial and ambiguous password generation options (#5974)
* feat(cli): add minNumber option and pass to generation service * feat(cli): add minSpecial option and pass to generation service * feat(cli): add ambiguous option and pass to generation service * refactor: extract utils to convert number and string options * feat(ts): add types to utils and options * feat: validate result of parsed value in convertNumberOption util
This commit is contained in:
@@ -253,4 +253,20 @@ export class CliUtils {
|
||||
static convertBooleanOption(optionValue: any) {
|
||||
return optionValue || optionValue === "" ? true : false;
|
||||
}
|
||||
|
||||
static convertNumberOption(optionValue: any, defaultValue: number) {
|
||||
try {
|
||||
if (optionValue != null) {
|
||||
const numVal = parseInt(optionValue);
|
||||
return !Number.isNaN(numVal) ? numVal : defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
} catch {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
static convertStringOption(optionValue: any, defaultValue: string) {
|
||||
return optionValue != null ? String(optionValue) : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user