class MapperA(PolymorphicMapper): id = Integer(read_only=True) name = String() object_type = String(choices=['event', 'task']) __mapper_args__ = { 'polymorphic_on': object_type, 'allow_polymorphic_marshal': False, }
class MapperBase(Mapper): __type__ = TestType password = String(error_msgs={'must_match': 'Passwords must match'}) password_confirm = String() def validate(self, output): if output.password != output.password_confirm: self.fields['password'].invalid('must_match')
class MapperBase(Mapper): __type__ = TestType name = String() age = Integer() def validate(self, output): if output.name == 'jack' and output.age != 36: raise MappingInvalid( {'name': 'wrong age for jack', 'age': 'jack must be 36'})
class MapperBase(Mapper): __type__ = TestType name = String(default='my default')
class MapperBase(Mapper): __type__ = TestType id = Integer() name = String()
class MapperBase(Mapper): __type__ = TestType id = Integer() name = String(name='my_name', source='name')
class MapperBase(Mapper): __type__ = TestType name = String(required=False, allow_none=False)
class MapperBase(Mapper): __type__ = TestType name = String(required=False) # allow_none=True is the default
class MapperBase(Mapper): __type__ = TestType name = String() #Â required=True is default