def user_exists(id): user_exists = False for user in User.select(): user_id = "{}{}".format(user.id, user.salt) if user_id == str(id): user_exists = True return user_exists
def email_exists(form, field): if User.select().where(User.email == field.data).exists(): raise ValidationError("Email already in use.")
def username_in_use(form, field): if User.select().where(User.username == field.data).exists(): raise ValidationError("Username already in use.")
def username_exists(form, field): if not User.select().where(User.username == field.data).exists(): raise ValidationError("User does not exist.")