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