From dfdeeb4d57c104e6d99da10b1e2e577761144ae9 Mon Sep 17 00:00:00 2001 From: Gabriel De Los Rios Date: Sun, 14 Dec 2025 20:12:49 -0300 Subject: [PATCH] feat: contact form group generator class --- src/app/utils/form-group-contact.spec.ts | 7 +++++++ src/app/utils/form-group-contact.ts | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/app/utils/form-group-contact.spec.ts create mode 100644 src/app/utils/form-group-contact.ts diff --git a/src/app/utils/form-group-contact.spec.ts b/src/app/utils/form-group-contact.spec.ts new file mode 100644 index 0000000..282099b --- /dev/null +++ b/src/app/utils/form-group-contact.spec.ts @@ -0,0 +1,7 @@ +import { FormGroupContact } from './form-group-contact'; + +fdescribe('FormGroupContact', () => { + it('should create an instance', () => { + expect(new FormGroupContact()).toBeTruthy(); + }); +}); diff --git a/src/app/utils/form-group-contact.ts b/src/app/utils/form-group-contact.ts new file mode 100644 index 0000000..521d697 --- /dev/null +++ b/src/app/utils/form-group-contact.ts @@ -0,0 +1,14 @@ +import { FormControl, FormGroup, Validators } from "@angular/forms"; + +export class FormGroupContact extends FormGroup{ + + constructor(name: FormValue = null, company: FormValue = null, phone: FormValue = null) { + super({ + name: new FormControl(name, [Validators.required, Validators.maxLength(55)]), + company: new FormControl(company, [Validators.required, Validators.maxLength(55)]), + phone: new FormControl(phone, [Validators.required, Validators.pattern( /^(\+?[\d]){12,15}$/ )]), + }); + } +} + +type FormValue = string| null;