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 TodoSchema(ma.Schema): id = ma.Integer() title = ma.String(required=True) done = ma.Boolean() created_by = ma.UUID() @validates('title') def validate_title(self, title): if len(title) <= 0: raise ValidationError("This field can't be empty.") elif len(title) > 120: raise ValidationError('max character of 120 characters exceeded.')
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 PostSchema(ma.Schema): id = ma.Integer() body = ma.String(required=True) created_by = ma.Integer() no_likes = ma.Integer() no_comments = ma.Integer() posted_date = ma.DateTime() liked = ma.Boolean() @validates('body') def validate_body(self, body): if len(body) <= 0: raise ValidationError("This field can't be empty.") elif len(body) > 255: raise ValidationError('max character of 255 characters exceeded.')
class FeatureRequestListArgsSchema(ma.Schema): limit = ma.Integer(required=False, validate=[validate.Range(1, 100)], missing=20) offset = ma.Integer(required=False, validate=[validate.Range(0)], missing=0) include_archived = ma.Boolean(required=False, missing=False) area = ma.Function(deserialize=load_from_id(Area), required=False) client = ma.Function(deserialize=load_from_id(Client), required=True, validate=[validate.NoneOf([None])]) search = ma.String(required=False) sort = ma.String( required=False, validate=[validate.OneOf(['priority', 'id', 'target_date'])], missing='priority')
class UpdateAuthorSchema(ma.Schema): first_name = ma.Str(required=True, validate=Length(max=100)) middle_name = ma.Str(validate=Length(max=100), missing=None) last_name = ma.Str(validate=Length(max=100), missing=None) bio = ma.Str(validate=Length(max=100000), missing=None) approved = ma.Boolean(missing=False)
class PostPostInputValidateSchema(ma.Schema): content = ma.Str(required=True, validate=Length(min=1)) title = ma.Str(required=True, validate=Length(min=1, max=30)) images = ma.List(ma.String(validate=Length(max=100), required=True)) is_anonymous = ma.Boolean(required=True)
class LoginSchema(ma.Schema): email = ma.String() password = ma.String() remember_me = ma.Boolean()
class CommentInputSchema(ma.Schema): content = ma.Str(required=True, validate=Length(min=1, max=100)) upper_comment_id = ma.Integer(required=False, allow_none=True) is_anonymous = ma.Boolean(required=True)