Currently, I am in the process of creating numerous new forms. For instance:
constructor(private formBuilder: FormBuilder) {
this.userForm = this.formBuilder.group({
'name': ['', Validators.required],
'email': ['', [Validators.required, ValidationService.emailValidator]],
'profile': ['', [Validators.required, Validators.minLength(10)]]
});
}
Instead of directly declaring these new values, wouldn't it be more efficient to create a separate class containing this information? Something like:
export class UserValidator{
// implementation details here
}
And then use it like:
this.userForm = this.formBuilder.group({
UserValidator
});
Is there any concrete example that demonstrates this approach?