1

I want to validate numbers between 2009-2059 in validator pattern at typeScript code. I tried many ways but could not find a way to do it ? Could you please look at the sample code and tell me how to fix it ?

Regards Alper

you can see the sample code below.

],'Input3': [this.guiTranformatorInput.JJJJ_input3,[
Validators.required,
 Validators.pattern('20[0-5][8-9]'),
  ]
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63

1 Answers1

2

your range pattern is wrong, try this

20((09)|([1-5][0-9]))

20: start with 20
(
09: literal 09
or
1-5 and 0-9
)

or using custom validator: https://stackoverflow.com/a/39848327/3676586

Community
  • 1
  • 1
Tiep Phan
  • 12,386
  • 3
  • 38
  • 41
  • 1
    hello Tiep.Thanks for your help. . Is there any direct pattern for the values between min and max number at typeScript ? I have to convert between values into an algoirthm. If not , I will try to implement algorithm myself – Tonyukuk Apr 20 '17 at 10:44
  • 1
    thank you Tiep.I will try the sample. I think regex seems impossible when I try to implement between 2012-2078. That's really to hard to implement an algorithm. What do you think about it ? – Tonyukuk Apr 20 '17 at 11:44