Python pydantic.constr() Examples

The following are 1 code examples of pydantic.constr(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pydantic , or try the search function .
Example #1
Source File: test_pydantic.py    From pydantic with MIT License 5 votes vote down vote up
def __init__(self, allow_extra):
        class Model(BaseModel):
            id: int
            client_name: constr(max_length=255)
            sort_index: float
            # client_email: EmailStr = None
            client_phone: constr(max_length=255) = None

            class Location(BaseModel):
                latitude: float = None
                longitude: float = None

            location: Location = None

            contractor: PositiveInt = None
            upstream_http_referrer: constr(max_length=1023) = None
            grecaptcha_response: constr(min_length=20, max_length=1000)
            last_updated: datetime = None

            class Skill(BaseModel):
                subject: str
                subject_id: int
                category: str
                qual_level: str
                qual_level_id: int
                qual_level_ranking: float = 0

            skills: List[Skill] = []

            class Config:
                extra = Extra.allow if allow_extra else Extra.forbid

        self.model = Model