add more friendly datetime validator to jsonschema

add `datetime` format (note, not the built-in `date-time`) to our json
schemas. this uses the iso8601 library to try and parse the string.

also, move `strict-rfc3339` and `rfc3987` (used by jsonschema to
validate `date-time` and `uri` formats respectively from test
requirements to regular requirements. if they're not installed,
validation silently succeeds, so validation wouldnt reject anything bad
on prod, only in unit tests.
This commit is contained in:
Leo Hemsted
2020-07-09 12:59:09 +01:00
parent 67f6dcae45
commit 61a5730596
5 changed files with 21 additions and 9 deletions

View File

@@ -11,8 +11,8 @@ create_broadcast_message_schema = {
'service_id': uuid,
'created_by': uuid,
'personalisation': {'type': 'object'},
'starts_at': {'type': 'string', 'format': 'date-time'},
'finishes_at': {'type': 'string', 'format': 'date-time'},
'starts_at': {'type': 'string', 'format': 'datetime'},
'finishes_at': {'type': 'string', 'format': 'datetime'},
'areas': {"type": "array", "items": {"type": "string"}},
},
'required': ['template_id', 'service_id', 'created_by'],
@@ -26,8 +26,8 @@ update_broadcast_message_schema = {
'title': 'Update broadcast_message',
'properties': {
'personalisation': {'type': 'object'},
'starts_at': {'type': 'string', 'format': 'date-time'},
'finishes_at': {'type': 'string', 'format': 'date-time'},
'starts_at': {'type': 'string', 'format': 'datetime'},
'finishes_at': {'type': 'string', 'format': 'datetime'},
'areas': {"type": "array", "items": {"type": "string"}},
},
'required': [],