0 votes
in Angular by

If your const minYear = 1900: and your const maxYear = 2100; what will the following custom validator return if a user enters the year 1987?

yearValidator(control: FormControl) {
     if (control.value.trim().length === 0) {
          return null;
     }
     const year = parseInt(control.value, 10);
     if (year >=minYear && year <= maxYear) {
          return { year: true };
     } 
1. yes
2. false
3. null
4. true

1 Answer

0 votes
by
Correct answer is :- true
...