Skip to content

Commit 2243c57

Browse files
add validators
1 parent 939279d commit 2243c57

File tree

2 files changed

+10
-6
lines changed
  • packages/models-library/src/models_library/api_schemas_rpc_async_jobs
  • services/storage/src/simcore_service_storage/modules/celery

2 files changed

+10
-6
lines changed

packages/models-library/src/models_library/api_schemas_rpc_async_jobs/async_jobs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
from typing import Any, TypeAlias
1+
from typing import Annotated, Any, TypeAlias
22
from uuid import UUID
33

4-
from pydantic import BaseModel
4+
from pydantic import BaseModel, StringConstraints
55

66
from ..products import ProductName
77
from ..progress_bar import ProgressReport
88
from ..users import UserID
99

1010
AsyncJobId: TypeAlias = UUID
11-
AsyncJobName: TypeAlias = str
11+
AsyncJobName: TypeAlias = Annotated[
12+
str, StringConstraints(strip_whitespace=True, min_length=1)
13+
]
1214

1315

1416
class AsyncJobStatus(BaseModel):

services/storage/src/simcore_service_storage/modules/celery/models.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from datetime import timedelta
22
from enum import StrEnum
3-
from typing import Any, Final, Protocol, TypeAlias
3+
from typing import Annotated, Any, Final, Protocol, TypeAlias
44
from uuid import UUID
55

66
from models_library.progress_bar import ProgressReport
7-
from pydantic import BaseModel
7+
from pydantic import BaseModel, StringConstraints
88

99
TaskContext: TypeAlias = dict[str, Any]
1010
TaskID: TypeAlias = str
11-
TaskName: TypeAlias = str
11+
TaskName: TypeAlias = Annotated[
12+
str, StringConstraints(strip_whitespace=True, min_length=1)
13+
]
1214
TaskUUID: TypeAlias = UUID
1315

1416
_CELERY_TASK_ID_KEY_SEPARATOR: Final[str] = ":"

0 commit comments

Comments
 (0)