File: models.py

package info (click to toggle)
python-lazy-model 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152 kB
  • sloc: python: 280; makefile: 7
file content (32 lines) | stat: -rw-r--r-- 531 bytes parent folder | download | duplicates (2)
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
from typing import List

from pydantic import validator, root_validator, Field

from lazy_model.main import LazyModel


class Simple(LazyModel):
    i: int
    s: str

    @validator("s")
    def s_upper(cls, v):
        return v.upper()

    @root_validator(pre=True)
    def check_card_number_omitted(cls, values):
        "i" in values
        return values


class Nested(LazyModel):
    s: Simple
    lst: List[Simple]


class Inherited(Simple):
    f: float


class WithAlias(LazyModel):
    i: int = Field(alias="_i_alias")