I am creating a library for automatically creating forms for objects in a project that I am working on.
The code base is in C #, and essentially we have a HUGE amount of different objects to store information about different things. If I send these objects to the client side as JSON, it is enough to simply program them to create a form for all properties.
The problem is that I want to be able to create an easy way to secure access and perform client-side validation. This must be done on the field at the field level.
In javascript, I would do this by creating a parallel object structure that had some kind of object in the nodes
{permissions: "someLevel", validator: someFunction} . With empty nodes, free permissions and universal validation are implied. This will allow me to simply iterate over the new object and the permission object, start the validation and process the result.Since I'm too much like a hammer, which is javascript, this is really the only way I can deal with this problem. My first implementation, therefore, uses reflection to allow me to consider objects as dictionaries that can be programmatically repeated, and then I just have PermissionRule object dictionaries that can be compared to.
Very javascripty. Very uncomfortable.
Is there a better way I can do this? Essentially, this is a way to associate a data set with each property, and then iterate over these properties.
Or am I doing it wrong?