How to validate year with format yyyy in ts?


#1

Friends,

I need to add validation for year eg: 2007 , how it can write ?

eg: for no i can write as


static isValid(control: FormControl): any {

       if(isNaN(control.value)){
           return {
               "not a number": true
           };
       }

       return null;
   }

but how to validate yyyy ? also check they will not provide years more than current year. eg must allow upto 2018 , not allow 2019 now…

please advise

Thanks

Anes