From 7a528b499ae00e4e95ab319e899546c627d007ed Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Sat, 12 Oct 2024 18:50:59 +0800 Subject: [PATCH] perf: import data validate platform --- apps/assets/serializers/asset/common.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index 5f1cee9ab..0a15597e4 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -309,6 +309,13 @@ class AssetSerializer(BulkOrgResourceModelSerializer, ResourceLabelsMixin, Writa }) return protocols_data_map.values() + def validate_platform(self, platform_data): + if self.Meta.model.__name__.lower() != platform_data.category: + raise serializers.ValidationError({ + 'platform': f"platform is not match: {platform_data.name}" + }) + return platform_data + @staticmethod def update_account_su_from(accounts, include_su_from_accounts): if not include_su_from_accounts: