[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:
Robyn MacCallum 2022-12-12 15:33:41 -05:00 committed by GitHub
parent bdfc2b0839
commit 9c0aa9e8d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -62,7 +62,7 @@
<button
bitButton
buttonType="primary"
[disabled]="orgInfoFormGroup.get('name').hasError('required')"
[disabled]="orgInfoFormGroup.get('name').invalid"
cdkStepperNext
>
Next

View File

@ -42,7 +42,7 @@ export class TrialInitiationComponent implements OnInit, OnDestroy {
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
orgInfoFormGroup = this.formBuilder.group({
name: ["", [Validators.required]],
name: ["", { validators: [Validators.required, Validators.maxLength(50)], updateOn: "change" }],
email: [""],
});
@ -148,6 +148,12 @@ export class TrialInitiationComponent implements OnInit, OnDestroy {
this.enforcedPolicyOptions = enforcedPasswordPolicyOptions;
});
}
this.orgInfoFormGroup.controls.name.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.orgInfoFormGroup.controls.name.markAsTouched();
});
}
ngOnDestroy(): void {

View File

@ -121,7 +121,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
}
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);
}