feat: 初始化学生管理系统代码
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from pydantic import BaseModel,Field,field_validator
|
||||
from typing import Optional
|
||||
from model import student
|
||||
|
||||
class Create_Stu_Mod(BaseModel):
|
||||
name: str = Field(min_length=3, max_length=15,description="姓名")
|
||||
hometown :Optional[str]=Field(min_length=2)
|
||||
school :str= Field(min_length=2,description="毕业院校")
|
||||
major : str=Field(description="专业")
|
||||
enroll_time:Optional[str]=Field(None,description="入学时间")
|
||||
graduate_time:Optional[str] = Field(None,description="毕业时间")
|
||||
education :Optional[str] = Field(description="学历")
|
||||
age :int=Field(gt=14,lt=60,description="年龄")
|
||||
gender : str = Field(max_length=10,description="性别")
|
||||
advisor_name:Optional[str]=Field(description="顾问名字")
|
||||
class_name:str=Field(description="班级名称")
|
||||
# 自定义校验器
|
||||
@field_validator('gender')
|
||||
def gender_validator(cls, gender):
|
||||
if gender not in ['男','女']:
|
||||
raise ValueError('性别输入有误')
|
||||
return gender
|
||||
Reference in New Issue
Block a user