Bird
0
0

Which of the following is the correct signature for a synchronous custom validator function in Angular?

easy📝 Syntax Q12 of 15
Angular - Reactive Forms
Which of the following is the correct signature for a synchronous custom validator function in Angular?
Afunction myValidator(event: Event): string
Bfunction myValidator(control: AbstractControl): ValidationErrors | null
Cfunction myValidator(control: FormGroup): void
Dfunction myValidator(value: string): boolean
Step-by-Step Solution
Solution:
  1. Step 1: Recall Angular validator function signature

    A synchronous custom validator takes an AbstractControl and returns ValidationErrors or null.
  2. Step 2: Match the correct function signature

    function myValidator(control: AbstractControl): ValidationErrors | null matches the required signature exactly, others do not fit Angular patterns.
  3. Final Answer:

    function myValidator(control: AbstractControl): ValidationErrors | null -> Option B
  4. Quick Check:

    Validator signature = function myValidator(control: AbstractControl): ValidationErrors | null [OK]
Quick Trick: Validator functions take AbstractControl and return errors or null [OK]
Common Mistakes:
MISTAKES
  • Using wrong parameter types like string or Event
  • Returning boolean instead of error object or null
  • Missing return type or returning void

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes