Suppose you have a web application with AngularJS front-end and .NET Web Services back-end. You need to apply a set of normalization rules for form values. For example, where saving an item Name you'd like to ensure that it contains only single spaces, that "Parkway" inside address is replaced with "Pkwy" and "Drive" is replaced with "Dr", that -90 > Latitude <= 90, etc. Most of these rules are easy to set in terms of regular expressions.
- You would like the system to be easily upgradable to a future version, which is going to read those rules from a database. (For now, you would probably specify rules in server-side C# code with an ability to pass them to a client code.)
- You would like to apply some of normalization rules on a client side - in AngularJS code.
- Ideally, you don't want to modify [much] of your AngularJS code when rules are updated on a server (or in a database).
- You would possibly like to double-check that values are normalized in your C# code before passing form values to a database.
What approach would you use to add such a flexible system of normalization rules to your application?