diff --git a/bublik/data/schemas/meta.json b/bublik/data/schemas/meta.json index f4f83e26..8767fd3f 100644 --- a/bublik/data/schemas/meta.json +++ b/bublik/data/schemas/meta.json @@ -68,7 +68,8 @@ "description": "List of patterns for assigning metas to the category", "items": { "type": "string", - "minLength": 1 + "minLength": 1, + "format": "regex" }, "uniqueItems": true } diff --git a/bublik/data/schemas/references.json b/bublik/data/schemas/references.json index 3b95b6ee..5df17250 100644 --- a/bublik/data/schemas/references.json +++ b/bublik/data/schemas/references.json @@ -15,8 +15,10 @@ "uri": { "type": "array", "items": { - "type": "string" + "type": "string", + "pattern": "^https?://" }, + "minItems": 1, "uniqueItems": true } }, @@ -26,6 +28,7 @@ ], "additionalProperties": false }, + "minItems": 1, "uniqueItems": true, "default": [ { @@ -46,7 +49,8 @@ "type": "string" }, "uri": { - "type": "string" + "type": "string", + "pattern": "^https?://" } }, "required": [ @@ -66,7 +70,8 @@ "type": "string" }, "uri": { - "type": "string" + "type": "string", + "pattern": "^https?://" } }, "required": [ diff --git a/bublik/data/serializers/config.py b/bublik/data/serializers/config.py index 2a382f54..3c18b10b 100644 --- a/bublik/data/serializers/config.py +++ b/bublik/data/serializers/config.py @@ -7,7 +7,7 @@ from django.contrib.auth import get_user_model from django.db import transaction import jsonschema -from jsonschema import validate +from jsonschema import FormatChecker, validate from rest_framework import serializers from rest_framework.serializers import ModelSerializer @@ -117,7 +117,7 @@ def ensure_json(config_content): json_schema = ConfigServices.get_schema(config_type, config_name) if json_schema: try: - validate(instance=content, schema=json_schema) + validate(instance=content, schema=json_schema, format_checker=FormatChecker()) except jsonschema.exceptions.ValidationError as jeve: jeve_msg = jeve.message[0].lower() + jeve.message[1:] msg = f'Invalid format: {jeve_msg}'