indexcalculation/Utils/Schemas/IndexSchemas.py

33 lines
722 B
Python
Raw Normal View History

2022-10-13 17:07:52 +08:00
from enum import Enum
from typing import List
import pydantic
from pydantic import BaseModel
ENameRegex = pydantic.constr(regex="^[a-z_]{1,}$")
2022-10-25 14:47:46 +08:00
CNameRegex = pydantic.constr(regex="^[\u4e00-\u9fa5a-zA-Z0-9]+$")
2022-10-13 17:07:52 +08:00
class Parameter(BaseModel):
ename: ENameRegex = "example_param"
2022-10-25 13:56:51 +08:00
cname: str = "示例参数"
2022-10-13 17:07:52 +08:00
description: str = "参数介绍文字"
class NatureEnum(Enum):
quantity = "定量"
quality = "定性"
class IndicatorDescription(BaseModel):
ename: ENameRegex = "example_indicator"
2022-10-25 13:56:51 +08:00
cname: str = "示例指标"
2022-10-13 17:07:52 +08:00
description: str = "指标介绍文字"
nature: NatureEnum
2022-12-22 15:34:49 +08:00
category: str
2022-10-13 17:07:52 +08:00
parameters: List[Parameter]
2022-11-09 00:53:00 +08:00
class Config:
use_enum_values = True