From fec694ef716104824da07d1ad71f642bd5d4c225 Mon Sep 17 00:00:00 2001 From: Fernanda Andrade <119636766+fe222004@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:42:32 -0500 Subject: [PATCH] constants --- .../auth/register/register.component.ts | 9 +++++---- src/app/constants/validation.constants.ts | 7 +++++++ .../appliance-registration.component.ts | 11 ++++++----- .../form-product/form-product.component.ts | 15 ++++++++------- 4 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 src/app/constants/validation.constants.ts diff --git a/src/app/components/auth/register/register.component.ts b/src/app/components/auth/register/register.component.ts index c0edff3..99b4275 100644 --- a/src/app/components/auth/register/register.component.ts +++ b/src/app/components/auth/register/register.component.ts @@ -9,6 +9,7 @@ import { RoutesConstants } from 'src/app/constants/routes.constants'; import { UrlsConstants } from 'src/app/constants/urls.constants'; import { DataTransferServiceService } from 'src/app/pages/services/data-transfer-service.service'; import { TranslateService } from '@ngx-translate/core'; +import { ValidationConstants } from 'src/app/constants/validation.constants'; @Component({ selector: 'app-register', @@ -44,16 +45,16 @@ export class RegisterComponent { '', [ Validators.required, - Validators.minLength(1), - Validators.maxLength(40), + Validators.minLength(ValidationConstants.NAME_MIN_LENGTH), + Validators.maxLength(ValidationConstants.NAME_MAX_LENGTH), ], ], last_name: [ '', [ Validators.required, - Validators.minLength(1), - Validators.maxLength(40), + Validators.minLength(ValidationConstants.NAME_MIN_LENGTH), + Validators.maxLength(ValidationConstants.NAME_MAX_LENGTH), ], ], email: [ diff --git a/src/app/constants/validation.constants.ts b/src/app/constants/validation.constants.ts new file mode 100644 index 0000000..2778221 --- /dev/null +++ b/src/app/constants/validation.constants.ts @@ -0,0 +1,7 @@ +export const ValidationConstants = { + NAME_MIN_LENGTH: 1, + NAME_MAX_LENGTH: 40, + BRAND_MIN_LENGTH: 2, + BRAND_MAX_LENGTH: 50, + ADDRESSS_MAX_LENGTH: 100, + }; \ No newline at end of file diff --git a/src/app/pages/appliance-registration/appliance-registration.component.ts b/src/app/pages/appliance-registration/appliance-registration.component.ts index 358b8fd..0a18f97 100644 --- a/src/app/pages/appliance-registration/appliance-registration.component.ts +++ b/src/app/pages/appliance-registration/appliance-registration.component.ts @@ -5,6 +5,7 @@ import { Router, ActivatedRoute } from '@angular/router'; import { PROVINCES_ECUADOR } from 'src/app/constants/constants'; import { DataTransferServiceService } from '../services/data-transfer-service.service'; import { ProductService } from '../services/product.service'; +import { ValidationConstants } from 'src/app/constants/validation.constants'; @Component({ selector: 'app-appliance-registration', @@ -45,17 +46,17 @@ export class ApplianceRegistrationComponent implements OnInit { '', [ Validators.required, - Validators.minLength(2), - Validators.maxLength(50), + Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH), + Validators.maxLength(ValidationConstants.BRAND_MAX_LENGTH), ], ], - problem_details: ['', [Validators.required, Validators.minLength(5)]], + problem_details: ['', [Validators.required, Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH)]], address: [ '', [ Validators.required, - Validators.minLength(5), - Validators.maxLength(100), + Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH), + Validators.maxLength(ValidationConstants.ADDRESSS_MAX_LENGTH), ], ], service_type: ['', [Validators.required]], diff --git a/src/app/pages/components/form-product/form-product.component.ts b/src/app/pages/components/form-product/form-product.component.ts index 718bc9f..bc6a8a3 100644 --- a/src/app/pages/components/form-product/form-product.component.ts +++ b/src/app/pages/components/form-product/form-product.component.ts @@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { DataTransferServiceService } from '../../services/data-transfer-service.service'; import { Router } from '@angular/router'; import { PROVINCES_ECUADOR } from 'src/app/constants/constants'; +import { ValidationConstants } from 'src/app/constants/validation.constants'; @Component({ selector: 'app-form-product', @@ -38,17 +39,17 @@ export class FormProductComponent { '', [ Validators.required, - Validators.minLength(2), - Validators.maxLength(50), + Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH), + Validators.maxLength(ValidationConstants.BRAND_MAX_LENGTH), ], ], - problem_details: ['', [Validators.required, Validators.minLength(5)]], + problem_details: ['', [Validators.required, Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH)]], address: [ '', [ Validators.required, - Validators.minLength(5), - Validators.maxLength(100), + Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH), + Validators.maxLength(ValidationConstants.ADDRESSS_MAX_LENGTH), ], ], service_type: ['', [Validators.required]], @@ -59,8 +60,8 @@ export class FormProductComponent { '', [ Validators.required, - Validators.minLength(2), - Validators.maxLength(50), + Validators.minLength(ValidationConstants.BRAND_MIN_LENGTH), + Validators.maxLength(ValidationConstants.ADDRESSS_MAX_LENGTH), ], ], });