Angular - Reactive FormsWhich of the following is the correct signature for a synchronous custom validator function in Angular?Afunction myValidator(event: Event): stringBfunction myValidator(control: AbstractControl): ValidationErrors | nullCfunction myValidator(control: FormGroup): voidDfunction myValidator(value: string): booleanCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall Angular validator function signatureA synchronous custom validator takes an AbstractControl and returns ValidationErrors or null.Step 2: Match the correct function signaturefunction myValidator(control: AbstractControl): ValidationErrors | null matches the required signature exactly, others do not fit Angular patterns.Final Answer:function myValidator(control: AbstractControl): ValidationErrors | null -> Option BQuick Check:Validator signature = function myValidator(control: AbstractControl): ValidationErrors | null [OK]Quick Trick: Validator functions take AbstractControl and return errors or null [OK]Common Mistakes:MISTAKESUsing wrong parameter types like string or EventReturning boolean instead of error object or nullMissing return type or returning void
Master "Reactive Forms" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - Zone.js and automatic detection - Quiz 1easy Angular Change Detection - Default change detection strategy - Quiz 12easy Angular Change Detection - Performance impact of change detection - Quiz 4medium HTTP Client - GET requests - Quiz 5medium Reactive Forms - Validators (required, minLength, pattern) - Quiz 13medium Reactive Forms - FormControl basics - Quiz 2easy RxJS Operators - tap operator for side effects - Quiz 4medium RxJS and Observables Fundamentals - Observable in component lifecycle - Quiz 3easy Services and Dependency Injection - How dependency injection works in Angular - Quiz 13medium Services and Dependency Injection - Why services are needed - Quiz 8hard