Skip to content

Commit a1279ff

Browse files
Parth SharmaParth Sharma
authored andcommitted
WEB-748: Improve email validation and fix translation namespace consistency
- Add required attribute to email input - Strengthen email regex validation - Align translation namespace with errors.* structure WEB-748: Improve email validation and translation namespace consistency - Add required attribute to email input - Strengthen email validation - Align translation namespace with errors.* structure email changed to optional#
1 parent d4be63c commit a1279ff

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/app/clients/client-stepper/client-general-step/client-general-step.component.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,21 @@
229229

230230
<mat-form-field class="flex-48">
231231
<mat-label>{{ 'labels.inputs.Email Address' | translate }}</mat-label>
232-
<input matInput formControlName="emailAddress" />
233-
@if (createClientForm.controls.emailAddress.errors?.email) {
232+
<input matInput formControlName="emailAddress" required />
233+
@if (createClientForm.controls.emailAddress.hasError('required')) {
234234
<mat-error>
235-
{{ 'error.Email not valid' | translate }}
235+
{{ 'labels.inputs.Email Address' | translate }}
236+
{{ 'labels.commons.is' | translate }}
237+
<strong>{{ 'labels.commons.required' | translate }}</strong>
238+
</mat-error>
239+
}
240+
241+
@if (
242+
createClientForm.controls.emailAddress.hasError('pattern') &&
243+
!createClientForm.controls.emailAddress.hasError('required')
244+
) {
245+
<mat-error>
246+
{{ 'errors.Email not valid' | translate }}
236247
</mat-error>
237248
}
238249
</mat-form-field>

src/app/clients/client-stepper/client-general-step/client-general-step.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ export class ClientGeneralStepComponent implements OnInit, OnDestroy {
133133
mobileNo: [''],
134134
emailAddress: [
135135
'',
136-
Validators.email
136+
[
137+
Validators.pattern('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$')
138+
]
137139
],
138140
dateOfBirth: [''],
139141
clientTypeId: [''],

0 commit comments

Comments
 (0)