def unique_username(form, field):
    if User.query.filter_by(username=field.data).first():
        raise ValidationError('Username is already registered.')

@auth.route('/register', methods=['POST'])
def register():
    inputs = RegisterInputs(request)
if inputs.validate():
    user = User.register_fromJSON(request.json)
db.session.add(user)
db.session.commit()
Using flask wtforms validators without using a form