I have a code, which basically validates the input fields by parsing the JSON Into Dict(user_data()). and then checking which fields might have entered wrong and storing into errors
errors = {}
for key, value in user_data().items():
if key in ["value1", "value2"]:
if validator1(value) == False
errors[key] = False
elif key in ["value3", "value4"]:
if validator2(value) == False
errors[key] = False
elif key in ["value5"]:
if validator3(value) == False
errors[key] = False
..........
..........
return errors
Is there a better way to refactor this code, and coding in this manner will it affect maintaining the code in future? Thanks