Validate start/end when scheduling queries (#7544)

* Validate start/end when scheduling queries

* Use chrono instead of Sugar
This commit is contained in:
Beto Dealmeida
2019-05-17 17:30:13 -07:00
committed by GitHub
parent 21a467094b
commit f0f719cb8d
4 changed files with 82 additions and 4 deletions

View File

@@ -858,13 +858,19 @@ To allow scheduled queries, add the following to your `config.py`:
},
'start_date': {
'type': 'string',
'format': 'date-time',
'title': 'Start date',
# date-time is parsed using the chrono library, see
# https://www.npmjs.com/package/chrono-node#usage
'format': 'date-time',
'default': 'tomorrow at 9am',
},
'end_date': {
'type': 'string',
'format': 'date-time',
'title': 'End date',
# date-time is parsed using the chrono library, see
# https://www.npmjs.com/package/chrono-node#usage
'format': 'date-time',
'default': '9am in 30 days',
},
'schedule_interval': {
'type': 'string',
@@ -890,6 +896,16 @@ To allow scheduled queries, add the following to your `config.py`:
),
},
},
'VALIDATION': [
# ensure that start_date <= end_date
{
'name': 'less_equal',
'arguments': ['start_date', 'end_date'],
'message': 'End date cannot be before start date',
# this is where the error message is shown
'container': 'end_date',
},
],
},
}