2012-02-22
 
Kategorie
 

Integrated Forms—Validation with External Services

 

ActiveForms is the best tool for building forms integrated with external services. An example of such possibilities is remote validation.

Each field can be configured so that its value is checked by an external service:

In the Properties field, specify the URL of the data validation service. When all validations are called, i.e. when the user tries to go to the next page of the form, the ActiveForms server will send an HTTP request to that address. The user will be allowed to move on, depending on the response received from the external server.

A meaningful validation has to take into account data entered in the form. That is why the specified address can contain field tags in the standard $fieldcode$ form. There can be any number of such tags. For example, the address of a validation service could be:

https://validators.server.com/client?VATID=$vatid$&name=$last_name$

Such an address will result in sending HTTP requests like:

https://validators.server.com/client?vatid=9876543210&name=Smith

provided that the form contained fields with the IDs vatid and last_name.

How do you know when a validation should let users proceed, and when it should stop them? Apart from the service address, we also provide a regular expression in the Properties field which will check whether the validation was successful. If the response from the server matches the specified regular expression, the user will be able to proceed.

The simplest cases of an Expression for successful validation could be fixed strings like “ok”, “OK”, “true”. Sometimes, you need a more complex expression, for example one that checks if an empty array was returned (^[^\[].*|\[[^\]].*$).

The message presented to the user is specified in ActiveForms. This allows you to use services which only return error codes, and AF takes care of the entire GUI. This works particularly well when creating multiple forms in many language versions which use the same validation services.

How will a form behave when a service isn’t working? That depends on the configuration as well. If you believe that your form must not accept unvalidated data, select the Halt user and show the message option. The user will see the specified error message just as if the validator worked but wouldn’t let the user proceed. Selecting the Nevermind, let user pass option means that the service unavailability will be ignored and the user will be able to submit the entry.

An external validator can be linked to any field. The validation URL doesn’t have to contain a $fieldcode$ which is linked to the validator. The location where a validation service is linked only affects the location where the validation message appears and the colouring of the incorrectly completed field.

Why use such a validation?

First of all, to implement validators that aren’t included in ActiveForms. If you need to check data with custom checksums, write your own service and link it to your form. You can use any technology and any programming language to write the service, and then host it on any server.

Second, this allows you to write validators that check entry data against external databases. You can verify if a user who wants to sign up for a check-up is your patient. You can check the credit standing of a client applying for a loan or whether a membership card has been already activated. There is no limit to the possible applications.

 
 
recent posts
3rd Apr 2014
Faster than ever!
5th Dec 2013
Live validation!
2nd Dec 2013
Features distilled
12th Mar 2012
Flicking Channels
26th Jan 2012
Your Own Error Page
9th May 2011
Box Properties
15th Apr 2011
Grouping Fields
13th Apr 2011
Form Versioning
24th Feb 2011
Form Access Modes
22nd Feb 2011
Required Fields
4th Feb 2011
Stats!