jeudi 16 avril 2020

Too many conditionals and validations in project

I have a Django project that takes JSON as input using drf APIs and performs variety of checks on that JSON and returns result accordingly. I am using JSON schema validation for verification of input. For further rules validations there are lot of checks for each input.

Example of the scenario is for a JSON input, I need to check sequence of specific fields/objetcs, lowercase/uppercase keys and values, match input keys with certain set of pre-defined data and much more.

My problem is that too many if else statements are making my code look ugly. I want to avoid that in a cleaner way. I am looking for suggestions to improve code quality. I have already divided most of it into different files.

TIA

Aucun commentaire:

Enregistrer un commentaire