InterviewHubPRO
Section Overview
Q267

Question 267 of 283

Part 10: Reactive Forms, Standalone Components, Signals & NgRx (256 - 283)

94%
Angular & Signals (283 Qs)•Part 10: Reactive Forms, Standalone Components, Signals & NgRx (256 - 283)

Can you give an example of built-in validators?

In reactive forms, you can use built-in validator like required and minlength on your input form controls. For example, the registration form can have these validators on name input field

js
this.registrationForm = new FormGroup({
  'name': new FormControl(this.hero.name, [
    Validators.required,
    Validators.minLength(4),
  ])
});

Whereas in template-driven forms, both required and minlength validators available as attributes.