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


Latest Articles

How to use WebAssembly inside OutSystems - Part 2

How to use WebAssembly inside OutSystems - Part 2

WebAssembly (WASM) is a new technology that is getting a lot of attention. We continue the use of Go compiled to WASM to show how we can use WASM inside OutSystems.

How to use WebAssembly inside OutSystems - Part 1

How to use WebAssembly inside OutSystems - Part 1

WebAssembly (WASM) is a new technology that's getting a lot of attention. On the browser, Javascript was the only programming language supported until the WASM Standard came out. OutSystems is designed to be a high performance platform, so we'll show you how to use WASM within OutSystems to take advantage of the extra performance points that WASM provides.

‍What’s new in OutSystems Developer Cloud

‍What’s new in OutSystems Developer Cloud

Have you heard about the OutSystems Developer Cloud and want to know more about what's new and what the big benefits are? Then this article is for you!