Example #1
0
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)
Example #2
0
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()
Example #3
0
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.')
Example #4
0
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()
Example #5
0
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
Example #6
0
class UserPasswordChangeSchema(ma.Schema):
    email = ma.Email(required=True)
    password = ma.String(required=True)
Example #7
0
class UserEmailSchema(ma.Schema):
    email = ma.Email(required=True)
Example #8
0
class LoginSchema(ma.Schema):
    email = ma.Email(required=True)
    password = ma.String(required=True)
Example #9
0
class RegisterSchema(ma.Schema):
    email = ma.Email()
    first_name = ma.String()
    last_name = ma.String()
    password = ma.String()