NG.VI · Angular 22 practice question
A developer wants to add validation to a field in a reactive form component. What is the recommended three-step sequence?
Check answer and explanation
Correct answer: Import a validator function, add the validator to the field, and add logic to handle the validation status
Explanation
Adding validation to a reactive form follows three steps: importing a validator function in the component, attaching it to the field, and adding logic to handle the validation status.
Common trap
Using ngModel and reading the DOM validity object does not match the reactive forms validation workflow. Creating a custom directive and registering it in an NgModule is unnecessary for standard reactive form validation.
Source: Angular docs: Reactive forms — Validating form input
Checked against the cited text on 2026-11-25.