-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup.py
52 lines (39 loc) · 1.27 KB
/
group.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from pydantic import field_validator
from .base import Base, EventGet, GroupGet
class GroupPatch(Base):
name: str | None = None
number: str | None = None
@classmethod
@field_validator("number")
def number_validate(cls, v: str):
if v is None:
return v
if len(v) not in [3, 4]:
raise ValueError("Group number must contain 3 or 4 characters")
if not v[0:3].isdigit():
raise ValueError("Group number format must be 'XYZ' or 'XYZM'")
return v
def __repr__(self):
return f"Group(name={self.name}, number={self.number})"
class GroupPost(Base):
name: str | None = None
number: str
@classmethod
@field_validator("number")
def number_validate(cls, v: str):
if v is None:
return v
if len(v) not in [3, 4]:
raise ValueError("Group number must contain 3 or 4 characters")
if not v[0:3].isdigit():
raise ValueError("Group number format must be 'XYZ' or 'XYZM'")
return v
def __repr__(self):
return f"Group(name={self.name}, number={self.number})"
class GetListGroup(Base):
items: list[GroupGet]
limit: int
offset: int
total: int
class GroupEvents(GroupGet):
events: list[EventGet]