From 6c125a3aa9b6c4dea69e599595e49805b9645bf9 Mon Sep 17 00:00:00 2001 From: Amol Sontakke Date: Mon, 22 Jun 2020 12:46:18 +0530 Subject: [PATCH 1/4] [#1285 #1286 #1287] Solved company name validation issue Added max length validation Added regex validation as per organization service Signed-off-by: Amol Sontakke --- .../add-company-modal.component.html | 18 +++++++++++++----- .../add-company-modal.component.ts | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html index 9b77ba2a..9cb20250 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html @@ -8,10 +8,18 @@
-
- Company name is required. +
+ + Company name is required + + + Company name should not be exceed 60 characters + + + Company name is invalid. +
-
-
diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts index 5fc5e340..4b7febf0 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts @@ -37,8 +37,8 @@ export class AddCompanyModalComponent implements OnInit { this.checkboxText1 = 'Create a complete CommunityBridge profile for your company.'; this.checkboxText2 = ' Leave unchecked if you do not want to create a full profile now.'; this.form = this.formBuilder.group({ - companyName: ['', Validators.compose([Validators.required, NameValidator.isValid])], - companyWebsite: ['', Validators.compose([Validators.required, UrlValidator.isValid])], + companyName: ['', Validators.compose([Validators.required, Validators.pattern('^[a-zA-Z0-9- ]*$'), Validators.maxLength(60)])], + companyWebsite: ['', Validators.compose([Validators.required, UrlValidator.isValid, , Validators.maxLength(255)])], }); } From fbd47b28ae1331b7b503550f72315cc0212b9e25 Mon Sep 17 00:00:00 2001 From: Amol Sontakke Date: Mon, 22 Jun 2020 12:53:59 +0530 Subject: [PATCH 2/4] Solved lint issue Signed-off-by: Amol Sontakke --- .../component/add-company-modal/add-company-modal.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts index 4b7febf0..af6a02c2 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts @@ -6,7 +6,6 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { UrlValidator } from 'src/app/shared/validators/website-validator'; import { ClaContributorService } from 'src/app/core/services/cla-contributor.service'; -import { NameValidator } from 'src/app/shared/validators/name-validator'; import { StorageService } from 'src/app/shared/services/storage.service'; @Component({ @@ -38,7 +37,7 @@ export class AddCompanyModalComponent implements OnInit { this.checkboxText2 = ' Leave unchecked if you do not want to create a full profile now.'; this.form = this.formBuilder.group({ companyName: ['', Validators.compose([Validators.required, Validators.pattern('^[a-zA-Z0-9- ]*$'), Validators.maxLength(60)])], - companyWebsite: ['', Validators.compose([Validators.required, UrlValidator.isValid, , Validators.maxLength(255)])], + companyWebsite: ['', Validators.compose([Validators.required, UrlValidator.isValid, Validators.maxLength(255)])], }); } From 2814f3b9a2fb1db345cd9e88a22a4af3aaee476e Mon Sep 17 00:00:00 2001 From: Amol Sontakke Date: Mon, 22 Jun 2020 13:02:19 +0530 Subject: [PATCH 3/4] [#1287] Solved error display issue Signed-off-by: Amol Sontakke --- .../add-company-modal.component.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html index 9cb20250..e0afb008 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html @@ -10,15 +10,15 @@ tabindex="-1" class="form-control" />
- +
Company name is required - - +
+
Company name should not be exceed 60 characters - - +
+
Company name is invalid. - +
@@ -70,4 +70,4 @@
- + \ No newline at end of file From 5d05882dda18ca4fd4ec937a829d65c3190da6fa Mon Sep 17 00:00:00 2001 From: Amol Sontakke Date: Tue, 23 Jun 2020 14:46:07 +0530 Subject: [PATCH 4/4] [#1285] Solved minlength issue of company name Changed url regex to allow only number in path Signed-off-by: Amol Sontakke --- src/app/config/app-settings.ts | 3 ++- .../add-company-modal/add-company-modal.component.html | 3 +++ .../component/add-company-modal/add-company-modal.component.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/config/app-settings.ts b/src/app/config/app-settings.ts index ba8b1349..d38d3774 100644 --- a/src/app/config/app-settings.ts +++ b/src/app/config/app-settings.ts @@ -12,5 +12,6 @@ export class AppSettings { public static HEADER_CONTENT_TYPE = 'application/json'; public static EMAIL_PATTERN = '[a-z|A-Z|0-9]+[@]+[a-z|A-Z|0-9]+[.]+([a-z|A-Z|0-9]){2}'; public static USERNAME_REGEX = '/^[a-zA-Z0-9_]{1,15}$/'; - public static URL_PATTERN = '^((ht|f)tp(s?))\://([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(/\S*)?$'; + public static COMPANY_NAME_REGEX = '^[a-zA-Z0-9- ]*$'; + public static URL_PATTERN = '^((ht|f)tp(s?))\://([0-9a-zA-Z\-]+\.)+[0-9a-zA-Z]{2,6}(\:[0-9]+)?(/\S*)?$'; } diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html index e0afb008..9412ed96 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.html @@ -13,6 +13,9 @@
Company name is required
+
+ Company name should be atleast 2 characters. +
Company name should not be exceed 60 characters
diff --git a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts index af6a02c2..d8489d4c 100644 --- a/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts +++ b/src/app/modules/corporate-contributor/component/add-company-modal/add-company-modal.component.ts @@ -7,6 +7,7 @@ import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { UrlValidator } from 'src/app/shared/validators/website-validator'; import { ClaContributorService } from 'src/app/core/services/cla-contributor.service'; import { StorageService } from 'src/app/shared/services/storage.service'; +import { AppSettings } from 'src/app/config/app-settings'; @Component({ selector: 'app-add-company-modal', @@ -36,7 +37,7 @@ export class AddCompanyModalComponent implements OnInit { this.checkboxText1 = 'Create a complete CommunityBridge profile for your company.'; this.checkboxText2 = ' Leave unchecked if you do not want to create a full profile now.'; this.form = this.formBuilder.group({ - companyName: ['', Validators.compose([Validators.required, Validators.pattern('^[a-zA-Z0-9- ]*$'), Validators.maxLength(60)])], + companyName: ['', Validators.compose([Validators.required, Validators.pattern(AppSettings.COMPANY_NAME_REGEX), Validators.minLength(2), Validators.maxLength(60)])], companyWebsite: ['', Validators.compose([Validators.required, UrlValidator.isValid, Validators.maxLength(255)])], }); }