From 1b836e78db2737ba5d1ae43da9828601a5a5c114 Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Mon, 25 Apr 2022 13:46:11 +0200 Subject: Rename timestamp_in_utc to timestamp, change format The format "date-time" in jsonschema is as defined in RFC 3339, which is about the same as ISO 8601. Validating this requires an additional package which is specified in python-jsonschema docs. --- src/schema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/schema.py b/src/schema.py index 9bdf130..fe2b76c 100644 --- a/src/schema.py +++ b/src/schema.py @@ -20,7 +20,7 @@ schema = { "ptr": {"type": "string"}, "abuse_mail": {"type": "string"}, "domain": {"type": "string"}, - "timestamp_in_utc": {"type": "string"}, + "timestamp": {"type": "string", "format": "date-time"}, "display_name": {"type": "string"}, "description": {"type": "string"}, "custom_data": { @@ -85,7 +85,7 @@ schema = { "ptr", "abuse_mail", "domain", - "timestamp_in_utc", + "timestamp", "display_name", # "description", # "custom_data", @@ -122,7 +122,7 @@ def as_index_list(): def validate_collector_data(json_blob): try: - jsonschema.validate(json_blob, schema) + jsonschema.validate(json_blob, schema, format_checker=jsonschema.FormatChecker()) except jsonschema.exceptions.ValidationError as e: return f"Validation failed with error: {e.message}" return "" -- cgit v1.1