aiteamutils 0.2.107__tar.gz → 0.2.109__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/PKG-INFO +1 -1
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/exceptions.py +1 -1
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/validators.py +34 -1
- aiteamutils-0.2.109/aiteamutils/version.py +2 -0
- aiteamutils-0.2.109/app/project/models.py +22 -0
- aiteamutils-0.2.107/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/.cursorrules +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/.gitignore +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/README.md +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/database.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/pyproject.toml +0 -0
- {aiteamutils-0.2.107 → aiteamutils-0.2.109}/setup.py +0 -0
@@ -84,8 +84,8 @@ class CustomException(Exception):
|
|
84
84
|
def __init__(
|
85
85
|
self,
|
86
86
|
error_code: ErrorCode,
|
87
|
-
detail: str,
|
88
87
|
source_function: str,
|
88
|
+
detail: str | None = None,
|
89
89
|
original_error: Optional[Exception] = None,
|
90
90
|
parent_source_function: Optional[str] = None
|
91
91
|
):
|
@@ -7,6 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|
7
7
|
from fastapi import Request
|
8
8
|
from inspect import signature
|
9
9
|
from pydantic import BaseModel, field_validator
|
10
|
+
from datetime import datetime, date
|
10
11
|
import re
|
11
12
|
|
12
13
|
from .exceptions import ErrorCode, CustomException
|
@@ -187,4 +188,36 @@ class Validator:
|
|
187
188
|
ErrorCode.VALIDATION_ERROR,
|
188
189
|
detail=f"{field_name}|{name}",
|
189
190
|
source_function="Validator.validate_name"
|
190
|
-
)
|
191
|
+
)
|
192
|
+
|
193
|
+
@staticmethod
|
194
|
+
def validate_date(value: Any, field_name: str = "date") -> Optional[date]:
|
195
|
+
"""날짜 형식 검증을 수행하는 메서드."""
|
196
|
+
if value is None or isinstance(value, date):
|
197
|
+
return value
|
198
|
+
if value == "":
|
199
|
+
return None
|
200
|
+
try:
|
201
|
+
return datetime.strptime(str(value), '%Y-%m-%d').date()
|
202
|
+
except Exception as e:
|
203
|
+
raise CustomException(
|
204
|
+
error_code=ErrorCode.INVALID_DATE_FORMAT,
|
205
|
+
detail=f"{field_name}|{value}",
|
206
|
+
source_function="Validator.validate_date",
|
207
|
+
original_error=str(e)
|
208
|
+
)
|
209
|
+
|
210
|
+
def date_validator(*field_names: str):
|
211
|
+
"""날짜 필드 유효성 검사 데코레이터
|
212
|
+
Args:
|
213
|
+
field_names: 검증할 필드명들
|
214
|
+
"""
|
215
|
+
def decorator(cls):
|
216
|
+
for field_name in field_names:
|
217
|
+
@field_validator(field_name, mode='before')
|
218
|
+
@classmethod
|
219
|
+
def validate(cls, value: Any, info: Any) -> Any:
|
220
|
+
return Validator.validate_date(value, field_name)
|
221
|
+
setattr(cls, f'validate_{field_name}', validate)
|
222
|
+
return cls
|
223
|
+
return decorator
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from sqlalchemy import String, Date, Enum
|
2
|
+
from sqlalchemy.dialects.postgresql import JSONB
|
3
|
+
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
4
|
+
from typing import Optional, List, Dict, Any, TYPE_CHECKING
|
5
|
+
from datetime import datetime, date
|
6
|
+
from pydantic import Field
|
7
|
+
|
8
|
+
from aiteamutils.base_model import BaseColumn, BaseSchema
|
9
|
+
from aiteamutils.exceptions import CustomException, ErrorCode
|
10
|
+
from aiteamutils.validators import date_validator
|
11
|
+
from app.utils.enums import ProjectStatus
|
12
|
+
|
13
|
+
if TYPE_CHECKING:
|
14
|
+
from app.task.models import Task
|
15
|
+
|
16
|
+
@date_validator('start_date', 'end_date')
|
17
|
+
class BaseProjectSchema(BaseSchema):
|
18
|
+
title: Optional[str] = None
|
19
|
+
user_ulid: Optional[str] = None
|
20
|
+
start_date: Optional[date] = None
|
21
|
+
end_date: Optional[date] = None
|
22
|
+
status: Optional[ProjectStatus] = None
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|