Knowledge Base

Search documentation by Keyword

4.3.2 Server side validation

When you have more complex validations or calculations you can use the server side validation. This way you can define an endpoint and BOA will sned a request from the client to the server. BOA will evaluate the response and will refresh your form you are working in.

With server side validation you can add multiple data fields to your request, and the response can also contain multiple fields. This way you can update and refresh all the fields (visible or hidden) on the form.

{
“display”: “VAT Nr.”,
“tooltip”: “VAT number of the customer.”,
“fieldname”: “btw_nr”,
“length”: 16,
“validation”: “/validation/checkbtwnummer?value=${btw_nr}&naam=${naam}”,
“inputtype”: “text”,
“block”: 1,
“newline”: false,
“labelwidth”: 2,
“fieldwidth”: 4
}

With the tag validation BOA will send a request to the API as soon as you enter data into the field. In this sample the endpoint /validation/checkbtwnummer will be called. It will send the content of the field btw_nr as value, and as second parameter the content of the field naam.

With the values send to the iAPI server, the validation can be done.

Response of server validation

After checking for validation, the response can be as follows:

Non valid:

{
“valid” : false,
“message” : “Must start with ‘xxxx’ to be valid.”
}

  • valid: true or false
  • message: the message to display when the validation isn’t valid.

Valid:

{
“valid” : true,
“data” : {
“btw_nr” : “1234598765”,
“adres2” : “VAT number check”}
}

  • valid: true of false
  • data: object with all the fields that has to be refreshed.
  • In this sample the fields btw_nr and adres2 will be replaced with the result of the validation.

As you can see the server side validation has a lot of power to refresh data. In a lot of situations data fields has to be replaced by values according to the input in other fields. Suppose you have a form with Quantity, price, discount and total. With server side validation you can calculate the total according to the values of the other fields. The total field can be refreshed as soon as one of the other fields has been changed.