Validations in model

Validations in model

  

Hi all,

I've been investigating a lot of development and modeling tools. Few of them allows setting validationrules per attribute in the model itself like range (min/max), a regexp, min, max, and (in some cases) even a js function. Also the validation message can be set there.  It seems to me that in OS we have to create validation rules in a action (or js) and with a lof of attributes in a form the actionflow can be a 'huge/difficult to read'. Would it be nice to propose OS (f.ex. as a tab in the Entity dialog) to add validations at that level and let OS handle the vaidation? Ofourse some validations you will have to code yourself but imo it would save a lot of 'manual' work. Just wanted to know what's your opinion on that.

Regards, Harry   

Hi Harry,

Basic validations on mandatory arguments being present and e.g. date values being valid are of course already possible client-side.

As for the action flow being "huge/difficult to read", well, the former can be the case if there a lot of input fields, but in general, and in my experience, a form/screen with a huge amount of inputs is bad UI design anyway, and should be avoided. As for the latter, I personally don't find things like this difficult to read at all:

Hi,


It actually depends.. 

there are client,  (js mostly)

client-server (actually client validation but done on the server)

and server-validations (the validation before stuff are made persistent)


Imho, what you are proposing are simple validations which are not worth to have them built-in by the platform, because they are so small and only used in small amounts.


however, if you propose something like "OnBeforeInsert" on entities I would favour that.


Hi,

Like Kilian said, the "Client & Server" validation already tackle the basic validation for "missing required information" and "wrong data type".

For specific validations, like "date MUST be BETWEEN this and that", "the value MUST be higher than zero", etc, this is usually "business-specific" and there is no way to the platform to know how you want to validate. But you can set some of those validations (like min/max) through the extended properties of the inputs. 

Regarding suggestion of J. of an OnBeforeInsert, this can be done through a common pattern that is to isolate the entities and make them "Read Only", creating public functions to Insert, Update, Delete, etc. In those functions, you put your validation and case some of the inputs are not valid, you can raise an exception or return an error code and warn the user about it.

This approach is very nice, because no matter what the programmers do in the Interface, you will always guarantee (at the best of possibilities), that only valid data are inserted into database.

Hope this helps :)

Cheers,
Eduardo Jauch


Solution

Hi all,

Thank you for sharing info and insights.

Regards, Harry

Solution