예제 #1
0
class Product(pdmodels.DefinedDict):

    name = pdmodels.StringField(is_required=True)
    price = pdmodels.FloatField(is_required=True)
    stock = pdmodels.IntField(default_value=0)

    product_info = pdmodels.VariableDefinedDictField("type", {
        "book": Book,
        "pen": Pen,
    })
예제 #2
0
 class Book(pdmodels.DefinedDict):
     id = pdmodels.StringField(regex="\d{4}-\d{4}-[A-Z]")
예제 #3
0
 class Book(pdmodels.DefinedDict):
     name = pdmodels.StringField()
예제 #4
0
 class Book(pdmodels.DefinedDict):
     status = pdmodels.StringField(default="available")
예제 #5
0
 class Book(pdmodels.DefinedDict):
     category = pdmodels.StringField(choices={"fiction", "non-fiction"})
예제 #6
0
class Pen(pdmodels.DefinedDict):

    color = pdmodels.StringField(is_required=True,
                                 choices={"red", "blue", "green"})
    type = pdmodels.StringField(fixed_value="pen")
예제 #7
0
class Book(pdmodels.DefinedDict):

    id = pdmodels.StringField(is_required=True, regex="\d{4}-[A-Z]+")
    author = pdmodels.StringField()
    type = pdmodels.StringField(fixed_value="book")
예제 #8
0
 class Book(pdmodels.DefinedDict):
     name = pdmodels.StringField(is_required=True)