I would like to set a specific type in typescript, that only accepts strings that follow a specific pattern. For example, to attribute it to a variable which has to be a date in the following format YYYY/MM/DD.
Examples:
type Date = "YYYY/MM/DD"; // obviously this type is dum and doesn't do the job, but you get the idea
let date1:Date = "2019/12/31" // OK
let date2:Date = "01/12/2000" // ERROR
let date3:Date = "someString" // ERROR
let date4:Date = "3190/01/31" // OK
let date5:Date = 1528917532543 // ERROR
let date6:Date = "20/12/31" // ERROR
let date7:Date = "2018/06/41" // ERROR !!
Is this possible?