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, })
class Book(pdmodels.DefinedDict): id = pdmodels.StringField(regex="\d{4}-\d{4}-[A-Z]")
class Book(pdmodels.DefinedDict): name = pdmodels.StringField()
class Book(pdmodels.DefinedDict): status = pdmodels.StringField(default="available")
class Book(pdmodels.DefinedDict): category = pdmodels.StringField(choices={"fiction", "non-fiction"})
class Pen(pdmodels.DefinedDict): color = pdmodels.StringField(is_required=True, choices={"red", "blue", "green"}) type = pdmodels.StringField(fixed_value="pen")
class Book(pdmodels.DefinedDict): id = pdmodels.StringField(is_required=True, regex="\d{4}-[A-Z]+") author = pdmodels.StringField() type = pdmodels.StringField(fixed_value="book")
class Book(pdmodels.DefinedDict): name = pdmodels.StringField(is_required=True)