def email_exists(form,field): if User.select().where(User.email == field.data).exists(): raise ValidationError('User with this email already exists.')