File: validation_field_descriptor.py

package info (click to toggle)
python-odmantic 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,488 kB
  • sloc: python: 8,646; sh: 110; javascript: 45; makefile: 34; xml: 13
file content (19 lines) | stat: -rw-r--r-- 525 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
from typing import List

from odmantic import Field, Model


class ExampleModel(Model):
    small_int: int = Field(le=10)
    big_int: int = Field(gt=1000)
    even_int: int = Field(multiple_of=2)

    small_float: float = Field(lt=10)
    big_float: float = Field(ge=1e10)

    short_string: str = Field(max_length=10)
    long_string: str = Field(min_length=100)
    string_starting_with_the: str = Field(regex=r"^The")

    short_str_list: List[str] = Field(max_items=5)
    long_str_list: List[str] = Field(min_items=15)