MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / validate

Method validate

api/features/serializers.py:387–401  ·  view source on GitHub ↗
(self, attrs: dict[str, Any])

Source from the content-addressed store, hash-verified

385 return name
386
387 def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
388 view = self.context["view"]
389 project_id = str(view.kwargs.get("project_pk"))
390 if not project_id.isdigit():
391 raise serializers.ValidationError("Invalid project ID.")
392
393 # If tags selected check they from the same Project as Feature Project
394 if any(tag.project_id != int(project_id) for tag in attrs.get("tags", [])):
395 raise serializers.ValidationError(
396 "Selected Tags must be from the same Project as current Feature"
397 )
398
399 self._validate_enforce_feature_owners(attrs)
400
401 return attrs
402
403 def _validate_enforce_feature_owners(self, attrs: dict[str, Any]) -> None:
404 project: Project = self.context["project"]

Callers 1

validateMethod · 0.45

Calls 2

getMethod · 0.45

Tested by

no test coverage detected