I have a Flask controller action with the following input validation routine, is there a way to write it more succinctly?
if 'firstName' and \
'lastName' and \
'age' \
not in request.json:
return flask.abort(400)
Perhaps something like this, although I'm not sure how to get the and operators to work:
mandatory_fields = ['firstName', 'lastName', 'age']
if mandatory_fields not in request.json:
return flask.abort(400)
Is the second code snippet possible?