File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,9 @@ class Meta:
57
57
58
58
def validate (self , data ):
59
59
self .validate_shared_resource ()
60
+ validators .check_if_team_name_exists (
61
+ data ["name" ], data ["organization_id" ]
62
+ )
60
63
return data
61
64
62
65
Original file line number Diff line number Diff line change @@ -235,3 +235,16 @@ def check_credential_types(
235
235
raise serializers .ValidationError (
236
236
f"The type of credential can only be one of { names } "
237
237
)
238
+
239
+
240
+ def check_if_team_name_exists (name : str , organization_id : int ):
241
+ if models .Team .objects .filter (
242
+ name = name , organization_id = organization_id
243
+ ).exists ():
244
+ raise serializers .ValidationError (
245
+ {
246
+ "name" : [
247
+ "A team with this name already exists in the organization."
248
+ ]
249
+ }
250
+ )
You can’t perform that action at this time.
0 commit comments