Skip to content

[Bugfix] #8364, #8176 fix address validation #3644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class AddressInputComponent implements OnInit, AfterViewInit, OnDestroy,
};

private readonly buildingPattern = Patterns.ubsHouseNumberPattern;
private readonly numericPattern = Patterns.numeric;
private readonly $destroy: Subject<void> = new Subject();
private viewInitialized = false;

Expand Down Expand Up @@ -270,12 +271,12 @@ export class AddressInputComponent implements OnInit, AfterViewInit, OnDestroy,
district: [this.addressData.getDistrict() ?? '', Validators.required],
houseNumber: [
this.address?.houseNumber ?? '',
[Validators.required, Validators.maxLength(4), Validators.pattern(this.buildingPattern)]
[Validators.required, Validators.maxLength(10), Validators.pattern(this.buildingPattern)]
],
houseCorpus: [this.address?.houseCorpus ?? '', emptyOrValid([Validators.maxLength(4), Validators.pattern(this.buildingPattern)])],
entranceNumber: [
this.address?.entranceNumber ?? '',
emptyOrValid([Validators.maxLength(2), Validators.pattern(this.buildingPattern)])
emptyOrValid([Validators.maxLength(3), Validators.pattern(this.numericPattern)])
],
placeId: [this.address?.placeId ?? ''],
addressComment: [this.address?.addressComment ?? '', Validators.maxLength(255)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('ErrorComponent ', () => {
}));

it('errorMessage should have correct value if we have maxlength error in "Entrance" field', () => {
Object.assign(component, { formElement: { errors: { maxlength: { requiredLength: 2 } } } });
Object.assign(component, { formElement: { errors: { maxlength: { requiredLength: 3 } } } });
fixture.detectChanges();
component.getType();
expect(component.errorMessage).toBe('input-error.max-length-entrance');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class UBSInputErrorComponent implements OnInit {
minlength: 'input-error.minlength-short',
maxlength: 'input-error.max-length',
maxlengthEntrance: 'input-error.max-length-entrance',
maxlengthHouse: 'input-error.max-length-house-number',
maxlengthHouse: 'input-error.max-length-house',
maxlengthHouseCorpus: 'input-error.max-length-house-corpus',
maxlengthStreet: 'input-error.max-length-street',
maxlengthCity: 'input-error.max-length-city',
Expand All @@ -53,7 +53,7 @@ export class UBSInputErrorComponent implements OnInit {
confirmPasswordMistmatch: 'ubs-client-profile.password-error-confirm',
requiredFromDropdown: 'personal-info.required-from-dropdown',
emailExist: 'input-error.email-exist',
invalidBinotelLink: 'input-error.binotel-link'
numericOnly: 'input-error.entrance-wrong'
};

ngOnInit() {
Expand Down Expand Up @@ -112,20 +112,20 @@ export class UBSInputErrorComponent implements OnInit {
return this.validationErrors.wrongNumber;
case Patterns.regexpPass.toString():
return this.validationErrors.passwordRequirements;
case Patterns.binotelLinkPattern.toString():
return this.validationErrors.invalidBinotelLink;
case Patterns.numeric.toString():
return this.validationErrors.numericOnly;
default:
return this.validationErrors.pattern;
}
}

getMaxlengthErrorMessage(maxlength: number): string {
switch (maxlength) {
case 2:
case 3:
return this.validationErrors.maxlengthEntrance;
case 4:
return this.validationErrors.maxlengthHouseCorpus;
case 5:
case 10:
return this.validationErrors.maxlengthHouse;
case 30:
return this.validationErrors.maxlengthCity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ export class CommentPopUpComponent implements OnInit {

initForm(): void {
this.commentForm = this.fb.group({
comment: [
this.comment?.trim(),
this.isLink ? [Validators.maxLength(255), Validators.pattern(Patterns.binotelLinkPattern)] : [Validators.maxLength(255)]
]
comment: [this.comment?.trim(), [Validators.maxLength(255)]]
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/ubs-admin/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@
"max-length-street": "The field should contain 1-120 characters",
"max-length-house": "The field should contain 1-10 characters",
"max-length-house-corpus": "The field should contain 1-4 characters",
"max-length-entrance": "The field should contain 1-2 characters",
"max-length-entrance": "The field should contain 1-3 characters",
"max-length-comment": "Maximum 255 characters are allowed",
"pattern": "Only alphabetic characters and special characters “-” (hyphen), “ ” (space) and “'” (apostrophe) are allowed",
"number-length": "The field should contain 12 characters",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/i18n/ubs-admin/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@
"max-length-street": "Поле повинно містити 1-120 символів",
"max-length-house": "Поле повинно містити 1-10 символів",
"max-length-house-corpus": "Поле повинно містити 1-4 символів",
"max-length-entrance": "Поле повинно містити 1-2 символи",
"max-length-entrance": "Поле повинно містити 1-3 символи",
"max-length-comment": "Дозволено вводити не більше, ніж 255 символів",
"pattern": "Дозволені тільки букви та спеціальні символи “-” (дефіс), “ ” (пропуск) та “'” (апостроф)",
"number-length": "Поле повинно містити 12 символів",
Expand Down
5 changes: 3 additions & 2 deletions src/assets/i18n/ubs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"city-wrong": "Only letters, numbers and hyphen, space, apostrophe, dot, comma are allowed",
"house-number": "Please select a house number",
"house-wrong": "Only letters, numbers and hyphen, slash are allowed",
"entrance-wrong": "Only numbers are allowed",
"letters-and-numeric-only": "Only letters and numbers are allowed",
"max-length-street": "The field should contain 1-120 characters",
"max-length-house": "The field should contain 1-4 characters",
"max-length-house": "The field should contain 1-10 characters",
"max-length-house-corpus": "The field should contain 1-4 characters",
"max-length-entrance": "The field should contain 1-2 characters",
"max-length-entrance": "The field should contain 1-3 characters",
"max-length-comment": "Maximum 255 characters are allowed",
"minlength-short": "The field contains insufficient characters",
"max-length": "The field should contain 1-30 characters",
Expand Down
4 changes: 2 additions & 2 deletions src/assets/i18n/ubs/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"entrance-wrong": "Дозволені лише цифри",
"max-length-city": "Поле повинно містити 1-30 символів",
"max-length-street": "Поле повинно містити 1-120 символів",
"max-length-house-number": "Поле повинно містити 1-4 символів",
"max-length-house": "Поле повинно містити 1-10 символів",
"max-length-house-corpus": "Поле повинно містити 1-4 символів",
"max-length-entrance": "Поле повинно містити 1-2 символи",
"max-length-entrance": "Поле повинно містити 1-3 символи",
"max-length-comment": "Дозволено вводити не більше, ніж 255 символів",
"minlength-short": "Поле містить недостатню кількість символів",
"max-length": "Поле повинно містити 1-30 символів",
Expand Down
1 change: 0 additions & 1 deletion src/assets/patterns/patterns.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-useless-escape */
export const Patterns = {
linkPattern: /^$|^https?:\/\//,
binotelLinkPattern: /^https:\/\/my\.binotel\.ua.*/,
NamePattern: /^[ґҐіІєЄїЇА-Яа-яa-zA-Z](?!.*\.$)(?!.*?\.\.)(?!.*?--)(?!.*?'')[-'ʼ’ ґҐіІєЄїЇА-Яа-я\w.]{0,29}$/,
ServiceNamePattern: /^[ґҐіІєЄїЇА-Яа-яa-zA-Z0-9!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\s]{1,30}$/,
TarifNamePattern: /^[ґҐіІєЄїЇА-Яа-яa-zA-Z](?!.*\.$)(?!.*?\.\.)(?!.*?)(?!.*?)[-'ʼ’ ґҐіІєЄїЇА-Яа-я+\w.]{0,255}$/,
Expand Down
Loading