Limit all dates asking to 3 months range

This commit is contained in:
Guntis Smaukstelis
2023-08-11 16:22:15 +03:00
parent a52eb2c54f
commit f1e68c6dba
7 changed files with 86 additions and 12 deletions
@@ -27,6 +27,21 @@ object ValidateRoutes {
}
}
object ValidateMonths {
def unapply(str: String): Option[List[LocalDate]] = {
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd")
val monthList = str
.split(",")
.toList
.flatMap(str => Try(LocalDate.parse(str + "01", formatter)).toOption)
monthList match {
case Nil => None
case list => Some(list)
}
}
}
object CityList {
def unapply(str: String): Option[List[String]] = {
str.split(",").toList match {