I'm writing an interface to be used by two applications. This interface should use some DoSomethingRequest
and DoSomethingResponse
classes to do the communication.
Is there any library that does some model validation, for example like Django's Model
?
I basically want to be able to say something like:
Object A must have a "text" property of type str(), a "number" property of type int(), an "items" property of type list(). In a DRY way.
I'm looking for something like the following, or better:
class MyEmbeddedModelClass(EmbeddedModel):text = TextField(required = True)class MyModel(Model):text = TextField(required = True)number = IntField(default = 0)items = ListField(EmbeddedModel)a = MyModel()
a.text = "aaaa"
a.number = 1
a.items = [MyEmbeddedModelClass("bbbb"),MyEmbeddedModelClass("cccc"),MyEmbeddedModelClass("dddd")
]
a.validate()
I know I can write my own, but I'd rather use a library if available, I'm a bit new to this.