mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[SG-664] Add org name length validation to inputs (#4111)
* Add maxLength validator to org name field * Disable next button if name has any error * Only check org name value changes * Add name length validator to normal create org flow
This commit is contained in:
@@ -62,7 +62,7 @@
|
|||||||
<button
|
<button
|
||||||
bitButton
|
bitButton
|
||||||
buttonType="primary"
|
buttonType="primary"
|
||||||
[disabled]="orgInfoFormGroup.get('name').hasError('required')"
|
[disabled]="orgInfoFormGroup.get('name').invalid"
|
||||||
cdkStepperNext
|
cdkStepperNext
|
||||||
>
|
>
|
||||||
Next
|
Next
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export class TrialInitiationComponent implements OnInit, OnDestroy {
|
|||||||
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
|
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
|
||||||
|
|
||||||
orgInfoFormGroup = this.formBuilder.group({
|
orgInfoFormGroup = this.formBuilder.group({
|
||||||
name: ["", [Validators.required]],
|
name: ["", { validators: [Validators.required, Validators.maxLength(50)], updateOn: "change" }],
|
||||||
email: [""],
|
email: [""],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -148,6 +148,12 @@ export class TrialInitiationComponent implements OnInit, OnDestroy {
|
|||||||
this.enforcedPolicyOptions = enforcedPasswordPolicyOptions;
|
this.enforcedPolicyOptions = enforcedPasswordPolicyOptions;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.orgInfoFormGroup.controls.name.valueChanges
|
||||||
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
.subscribe(() => {
|
||||||
|
this.orgInfoFormGroup.controls.name.markAsTouched();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.createOrganization) {
|
if (this.createOrganization) {
|
||||||
this.formGroup.controls.name.addValidators(Validators.required);
|
this.formGroup.controls.name.addValidators([Validators.required, Validators.maxLength(50)]);
|
||||||
this.formGroup.controls.billingEmail.addValidators(Validators.required);
|
this.formGroup.controls.billingEmail.addValidators(Validators.required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user