Employed a regular expression pattern in the PeriodConverter to check the period format first.

This commit is contained in:
2020-07-23 22:13:17 +08:00
parent d88d3942d2
commit 25383a3ae6
3 changed files with 7 additions and 5 deletions

View File

@ -38,7 +38,9 @@ class TransactionTypeConverter:
class PeriodConverter:
"""The path converter for the period."""
regex = ".+"
regex = ("([0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?)|"
"([0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?)?-"
"([0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?)?")
def to_python(self, value):
"""Returns the period by the period specification.