FREE OutSystems Workshops - Build an OutSystems App in 1 hour | ENROLL NOW

Tech Bites - Should we validate form data on server-side?

< Back to Blog

Hi, and welcome to another Tech Bite!

When including forms in applications, developers often wonder if they need to re-validate data on the server side after having checked it on the client. Why go to the trouble of checking the data twice?

Even using mandatory fields and validating the data on the button's "client action," what happens on the device is never safe and ready to use.

That's why the OutSystems Platform automatically reminds us to validate all data on the server side before saving!

We should add an "if node" in our application and validate the Price input parameter. Drag the IF node to your logic and write the condition.

If the validation fails, the logic should raise an exception. Pick a Raise Exception Node and select a new User Exception for the first validation. 

Later, you will be reusing this exception, so let’s rename it to something meaningful like Invalid Parameters. 

Now, return to your Exception node and configure the Exception Message field with the message you will display to the user.

That raised exception could be handled on the Screen's Client Action with an Exception Handler node, but it is unnecessary. Because, for all user exceptions without a handler, the Global Exception Handler of your module will do the work. 

You can check it on the On Exception action of the "Common" UI Flow. This will trigger an error message to be shown to the end user.

Let's simulate an issue in the data typed by a user. To be able to test the exception in runtime, we will temporarily disable the client-side validation.

Now, if we try to input invalid data, such as a negative value in the Price field, an error message will be displayed! Meaning the application raised an exception because the data was not valid.

Thanks for watching.

Turn Up Academy

Apply to our Turn Up Boot Camp

AND BECOME THE NEXT OUTSYSTEMS CERTIFIED DEVELOPER
(
Instructor
)

Latest Articles

Tech Bites - Should we validate form data on server-side?

Should we validate form data on server-side

When including forms in applications, developers often wonder if they need to re-validate data on the server side after having checked it on the client. Why go to the trouble of checking the data twice?

Tech Bites
The Top 5 Mistakes Handling Asynchronous Data In Outsystems Reactive Apps And How To Avoid Them

The Top 5 Mistakes Handling Asynchronous Data In Outsystems Reactive Apps

When developing an OutSystems reactive web app, you would expect to display data quickly, but it doesn't always happen. Do you know why? We'll explore the reasons and how to tackle them.

DevZone
Tech Bites - How to use Screen templates

How to use Screen templates

Did you know that the OutSystems Platform has tens of screen templates to help you quickly put together your apps? Let me show you how you can use them.

Tech Bites