def validate_new_name(form, field): """Validate that the new account name isn't taken""" if Account.count(Q.name == field.data) > 0: raise ValidationError('Account name already taken.')
def validate_name(form, field): """Validate that the account name exists""" if Account.count(Q.name == field.data) == 0: raise ValidationError('Account not found.')