1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-24 16:43:27 +00:00

add validator

This commit is contained in:
William Martin
2025-01-07 16:24:13 -05:00
parent 966e8d3fb8
commit c1a6e6e44a
2 changed files with 11 additions and 1 deletions

View File

@@ -7,7 +7,13 @@
<bit-card>
<bit-form-field disableMargin>
<bit-label>{{ "length" | i18n }}</bit-label>
<input bitInput formControlName="length" type="number" (change)="save('length')" />
<input
bitInput
formControlName="length"
type="number"
(change)="save('length')"
[min]="minLength"
/>
<bit-hint>{{ lengthBoundariesHint$ | async }}</bit-hint>
</bit-form-field>
</bit-card>

View File

@@ -93,6 +93,8 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
[Controls.avoidAmbiguous]: [!Generators.password.settings.initial.ambiguous],
});
protected minLength: number;
private get numbers() {
return this.settings.get(Controls.number);
}
@@ -139,6 +141,8 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
}
this.lengthBoundariesHint.next(boundariesHint);
this.minLength = constraints?.minLength?.min ?? 5;
// skips reactive event emissions to break a subscription cycle
this.settings.patchValue(state, { emitEvent: false });
});