diff options
author | Ernst Widerberg <ernst@sunet.se> | 2022-04-25 13:46:11 +0200 |
---|---|---|
committer | Ernst Widerberg <ernst@sunet.se> | 2022-04-25 13:46:11 +0200 |
commit | 1b836e78db2737ba5d1ae43da9828601a5a5c114 (patch) | |
tree | eb41ef3cf7ece326a49021302165a3cb4c8de1d7 /src | |
parent | 2aebcdeca17f9b46d90f5255dd4d03caa358701e (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/schema.py | 6 |
1 files changed, 3 insertions, 3 deletions
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 "" |