aiteamutils 0.2.108__tar.gz → 0.2.110__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.108
3
+ Version: 0.2.110
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -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,48 @@ 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:
197
+ return None
198
+ if isinstance(value, date):
199
+ return value
200
+ if value == "" or not value:
201
+ return None
202
+ try:
203
+ return datetime.strptime(str(value), '%Y-%m-%d').date()
204
+ except Exception as e:
205
+ raise CustomException(
206
+ error_code=ErrorCode.INVALID_DATE_FORMAT,
207
+ detail=f"{field_name}|{value}",
208
+ source_function="Validator.validate_date",
209
+ original_error=str(e)
210
+ )
211
+
212
+ def date_validator(*field_names: str):
213
+ """날짜 필드 유효성 검사 데코레이터
214
+ Args:
215
+ field_names: 검증할 필드명들
216
+ """
217
+ def decorator(cls):
218
+ for field_name in field_names:
219
+ @field_validator(field_name, mode='before')
220
+ @classmethod
221
+ def validate(cls, value: Any, info: Any) -> Any:
222
+ try:
223
+ return Validator.validate_date(value, field_name)
224
+ except CustomException as e:
225
+ raise e
226
+ except Exception as e:
227
+ raise CustomException(
228
+ error_code=ErrorCode.INVALID_DATE_FORMAT,
229
+ detail=f"{field_name}|{value}",
230
+ source_function=f"date_validator.{field_name}",
231
+ original_error=str(e)
232
+ )
233
+ setattr(cls, f'validate_{field_name}', validate)
234
+ return cls
235
+ return decorator
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.110"
@@ -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
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.108"
File without changes
File without changes
File without changes