class UserSchema(ma.Schema): username = ma.Str(required=True) email = ma.Email(required=True) class Meta: fields = ('username', 'email') @post_load def make_user(self, data, **kwargs): return User(**data)
class UserSchema(ma.Schema): id = ma.Integer() username = ma.String(required=True) email = ma.Email(required=True) password = ma.String(required=True) profile_pic = ma.String() bio = ma.String() location = ma.String() website = ma.Url() is_active = ma.Boolean() is_admin = ma.Boolean() joined_date = ma.DateTime()
class UserSchema(ma.Schema): public_id = ma.UUID() first_name = ma.String(required=True) last_name = ma.String(required=True) email = ma.Email(required=True) password = ma.String(required=True) profile_pic = ma.String() active = ma.Boolean() todos = ma.Nested(TodoSchema, many=True) @validates('password') def validate_password(self, password): if len(password) < 5: raise ValidationError('Password min character is 5.')
class UserSchema(ma.SQLAlchemySchema): """User Marshmallow Schema""" class Meta: model = User exclude = "password_hash" public_id = ma.auto_field(dump_only=True) firstname = ma.auto_field() lastname = ma.auto_field() company = ma.auto_field() email = ma.Email(required=True) phone = ma.auto_field() personal_url_1 = ma.URL() personal_url_2 = ma.URL() personal_url_3 = ma.URL() password = ma.String( required=True, validate=validate_password_constraints, load_only=True ) projects = ma.auto_field()
class UserSchema(ma.SQLAlchemySchema): class Meta: model = User unknown = EXCLUDE id = ma.auto_field() username = ma.String( required=True, validate=[validate.Length(min=1, max=80), validate_unique_username]) email = ma.Email( required=True, validate=[validate.Length(min=1, max=120), validate_unique_email]) password = ma.auto_field(column_name='password_hash', load_only=True, required=True, validate=[validate.Length(min=8, max=128)]) created_at = ma.auto_field(dump_only=True) updated_at = ma.auto_field(dump_only=True) @post_load def create_user(self, data, **kwargs): user = User(**data) user.set_password(data['password_hash']) return user
class UserPasswordChangeSchema(ma.Schema): email = ma.Email(required=True) password = ma.String(required=True)
class UserEmailSchema(ma.Schema): email = ma.Email(required=True)
class LoginSchema(ma.Schema): email = ma.Email(required=True) password = ma.String(required=True)
class RegisterSchema(ma.Schema): email = ma.Email() first_name = ma.String() last_name = ma.String() password = ma.String()