From aab352eb05596bb9459f0463e0f56af2802ce057 Mon Sep 17 00:00:00 2001 From: matusdrobuliak66 Date: Thu, 24 Oct 2024 10:15:14 +0200 Subject: [PATCH] review @sanderegg --- .../src/models_library/projects_state.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/models-library/src/models_library/projects_state.py b/packages/models-library/src/models_library/projects_state.py index 9218639c74c..f9d9bf26983 100644 --- a/packages/models-library/src/models_library/projects_state.py +++ b/packages/models-library/src/models_library/projects_state.py @@ -5,7 +5,7 @@ from enum import Enum, unique from typing import Any, ClassVar -from pydantic import BaseModel, Extra, Field, validator +from pydantic import BaseModel, Extra, Field, root_validator, validator from .projects_access import Owner @@ -91,13 +91,13 @@ def check_status_compatible(cls, v, values): raise ValueError(msg) return v - @validator("owner", always=True) + @root_validator(pre=True) @classmethod - def check_owner_compatible(cls, v, values): + def check_owner_compatible(cls, values): if ( values["value"] is True - and v is None - and values.get("status") + and values.get("owner") is None + and values["status"] in [ status.value for status in ProjectStatus @@ -106,7 +106,7 @@ def check_owner_compatible(cls, v, values): ): msg = "Owner must be specified when the project is not in the 'MAINTAINING' status." raise ValueError(msg) - return v + return values class ProjectRunningState(BaseModel):