I'm building a API that gets called from web / mobile applications written using Ionic (web languages on mobile), which uses Angular.js.
We want to be able to do server side validation of forms but don't want to have to rewrite functions constantly to match each form. However, we need to make sure the forms are verified completely, containing all intended fields, and having no extra fields, Since form submissions like this are easily modified by the user.
Would having a universal handler for the form be a good idea? Something that looped through all submitted fields and using a switch to match their type to a certain formatting? And to ensure it was the right set of fields, having a form identifier that reads the list of fields it should have from a database?