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;