I have a form with currently one field description and I'm building that form from a model as given below
view-model.ts
export class ViewModel {
description = '';
}
view-action.component.ts
export class ViewActionComponent {
constructor(public fb: FormBuilder) {
this.groupForm = this.fb.group(new ViewModel());
}
...
}
The form works perfectly fine. Now the problem is I need to add validator for that description field (like entering only text). Is there any way to add a validator for description in view-model.ts file so that I wont modify view-action.component.ts file?
So the basic idea is, If I need to add another field with validator, I can do it in the ViewModel itself.