class UserRegisterParse(BaseMarshmallow): email = fields.Email(validate=[validate.str_range(0, 128)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True) password_ = fields.String(validate=[validate.str_range(8, 16)], required=True) code = fields.String(validate=[validate.str_range(6, 6)], required=True)
class UserSchema(ma.Schema): """ User serialization/deserialization schema """ class Meta: ordered = True first_name = fields.Str(required=False) last_name = fields.Str(required=False) email = fields.Email(required=False) username = fields.Str(required=False, validate=username_is_valid) public_key = fields.Str(dump_only=True) @validates_schema def check_for_username_or_email(self, data, **kwargs): if not any(lambda x: x in data.keys() for x in ["username", "email"]): raise ValidationError( 'At least one of "email" or "username" should be informed')
class RegisterSchema(Schema): name = fields.String(required=False, validate=Length(min=3, max=50)) email = fields.Email(required=True, validate=Length(min=3, max=50)) password = fields.String(required=True, validate=Length(min=3, max=50))
class LoginSchema(Schema): email = fields.Email(required=True, validate=Length(min=3, max=50)) password = fields.String(required=True, validate=Length(min=3, max=50)) remember_me = fields.Boolean(required=False, default=False, missing=False)
class UserLoginParse(BaseMarshmallow): username = fields.Email(validate=[validate.str_range(0, 128)], required=True) password = fields.String(validate=[validate.str_range(8, 16)], required=True)
class SendEmailCodeParse(BaseMarshmallow): email = fields.Email(validate=[validate.str_range(0, 128)], required=True)
class UserSchema(Schema): email = fields.Email(required=True) password = fields.Str(required=True, validate=not_empty, allow_none=False)
class UserSchema(Schema): email = fields.Email(required=True) name = fields.String() address = fields.String(required=True)