How to: Moqui client/server side custom validations?

93 views Asked by At

If one has to perform business rules related validations and some cross field validations; on data entered in html-form-fields on screen, how can it be done?

Does the Moqui framework provide any inbuilt-support for this? Is there any guide/tutorial available for this?

Update: Hi David, thanks for your time. Below is the detailed requirement for validation.

1) Need to show the validation message on submit (before the request is sent to server) rather than after the request is processed on server. e.g. When I open a dialog/screen to create/update some record, than I pass invalid number(e.g. 'abc') value in field and click submit; the FORM gets submitted and the response (on next screen) is:

The value [abc] is not valid for type [java.lang.Long] (for field xyz) etc.

So, how can the FORM-submission be prevented and how to show message to user before submitting and on the same screen not on next screen? (ie. how to implement validation similar to javascript validation at field/FORM-submit level). And this may be required not only on just one screen but on many other screens may have thier own screen specific different validation rules for various fields.

Traditional way of adding bunch of .js files in header/footer doesn't look right; because how all the FORMs would know(without making some changes to how the FORM gets generated) which js-function to invoke and when? And also I don't want to make any custom change in framework which may not be compliant with any future upgrade of moqui or may require lot of re-work to integrate it smoothlessly for future upgrades.

2) Cross field validation i.e. filed1 is to be validated based on result of some calculation of values in field2 and/or field3 etc. How can this be done on client-side?

0

There are 0 answers