feat: contact form group generator class
This commit is contained in:
7
src/app/utils/form-group-contact.spec.ts
Normal file
7
src/app/utils/form-group-contact.spec.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { FormGroupContact } from './form-group-contact';
|
||||
|
||||
fdescribe('FormGroupContact', () => {
|
||||
it('should create an instance', () => {
|
||||
expect(new FormGroupContact()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
14
src/app/utils/form-group-contact.ts
Normal file
14
src/app/utils/form-group-contact.ts
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user