Skip to content

Commit

Permalink
constants
Browse files Browse the repository at this point in the history
  • Loading branch information
fe222004 committed Jul 26, 2024
1 parent 9564066 commit fec694e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
9 changes: 5 additions & 4 deletions src/app/components/auth/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: [
Expand Down
7 changes: 7 additions & 0 deletions src/app/constants/validation.constants.ts
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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]],
Expand Down
15 changes: 8 additions & 7 deletions src/app/pages/components/form-product/form-product.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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]],
Expand All @@ -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),
],
],
});
Expand Down

0 comments on commit fec694e

Please sign in to comment.