Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Angular - Reactive Forms
Identify the error in this code snippet:
const control = new FormControl('', Validators.required, Validators.minLength(3));
AValidators.minLength should be a string
BValidators should be passed as an array
CFormControl requires a third argument for validators
DValidators.required cannot be used with minLength
Step-by-Step Solution
Solution:
  1. Step 1: Check FormControl constructor signature

    Validators must be passed as an array in the second argument.
  2. Step 2: Identify incorrect argument usage

    Passing multiple validators as separate arguments is invalid syntax.
  3. Final Answer:

    Validators should be passed as an array -> Option B
  4. Quick Check:

    Validators array required for multiple validators [OK]
Quick Trick: Use array to pass multiple validators [OK]
Common Mistakes:
MISTAKES
  • Passing validators as separate args
  • Wrong argument position
  • Using string for minLength

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes