Skip to content

Commit

Permalink
['Редагування закладу' page] Incorrect validation of the 'Вулиця' fie…
Browse files Browse the repository at this point in the history
…ld with correct data #900 (#1028)

* fix

* fix

* fix
  • Loading branch information
Olya-web7 authored Apr 4, 2022
1 parent 0093888 commit 5f9b505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/app/shared/constants/regex-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ export const DATE_REGEX: RegExp = /[^0-9./-]*/g;
export const NAME_REGEX: RegExp = /^[А-Яа-яЇїІіЄєЁёҐґ'’-]*$/;
export const BIRTH_CERTIFICATE_REGEX: RegExp = /^[A-Za-zА-Яа-яЇїІіЄєЁёҐґ'’\s\d-№]*$/;
export const WEB_INST_FB_REGEX: RegExp = /^[А-Яа-яЇїІіЄєЁёҐґ'’.,\d\/-]*$/;

export const EDRPOUIPN_REGEX: RegExp = /^[A-Za-zА-Яа-яЇїІіЄєЁёҐґ'’`.,\s\d-№]*$/;

Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,24 @@ export class CreateContactsFormComponent implements OnInit, OnDestroy {
this.ActualAddressFormGroup.enable();
this.ActualAddressFormGroup.markAsUntouched();
this.setValidators();
this.provider?.actualAddress && this.ActualAddressFormGroup.get('id').setValue(this.provider.actualAddress.id);
this.provider?.actualAddress && this.ActualAddressFormGroup.get('id')
.setValue(this.provider.actualAddress.id);
}
});
}
/**
* This method add validators to teh form-group when actual address is not teh same as legal address
*/
private setValidators(): void {
const addValidator = (formControlTitle: string) => (formControlTitle !== 'buildingNumber') ? Validators.pattern(TEXT_REGEX) : Validators.pattern(TEXT_WITH_DIGITS_REGEX);
const addValidator = (formControlTitle: string) => (formControlTitle === 'buildingNumber'
|| formControlTitle === 'street')
? Validators.pattern(TEXT_WITH_DIGITS_REGEX)
: Validators.pattern(TEXT_REGEX);

Object.keys(this.ActualAddressFormGroup.controls).forEach((formControlTitle: string) => {
this.ActualAddressFormGroup.get(formControlTitle).setValidators([addValidator(formControlTitle), Validators.required]);
});
this.ActualAddressFormGroup.get(formControlTitle)
.setValidators([addValidator(formControlTitle), Validators.required]);
});
}

ngOnDestroy(): void {
Expand Down

0 comments on commit 5f9b505

Please sign in to comment.