Skip to content
Snippets Groups Projects
Commit a6e70237 authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST
Browse files

[databases][serializers] Add declaration validation

parent c5722732
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@
# #
###############################################################################
from django.conf import settings
from rest_framework import serializers
from ..common.serializers import VersionableSerializer
......@@ -104,6 +106,12 @@ class DatabaseCreationSerializer(serializers.ModelSerializer):
]
beat_core_class = beat.core.database.Database
def validate_declaration(self, declaration):
obj = self.Meta.beat_core_class(prefix=settings.PREFIX, data=declaration)
if not obj.valid:
raise serializers.ValidationError(obj.errors)
return declaration
def validate(self, data):
user = self.context.get("user")
name = self.Meta.model.sanitize_name(data["name"])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment