Site icon TestingDocs.com

User input validation in Raptor flowchart

Introduction

In this article, we will learn how to perform user input validation in the RAPTOR flowchart. In this example, we will prompt the user to enter a number and we will display the number. If the input is invalid we will display an error message to the user. The idea is to understand how to validate the user input to the flowchart.

User input validation

Sometimes, we get invalid inputs. For example, we asked the user to input a number. But, the user might enter invalid inputs like strings, etc. In this flow chart, we will see how to handle the situation.

Steps:

 

 

We will store the input into a variable called n.

Now place a Selection symbol.

 

 

 

We will check the input with function Is_Number().

Is_Number(n)

This function returns True when the argument n is a number. If the input argument n is not a number the function returns false. We can leverage this function using a IF control structure to validate number input.

In this flowchart context, valid input is a number. Anything, other than a number is invalid input. For example, if we enter String instead of a number, the flowchart would prompt that the input is invalid.

 

 

Is_Number() function returns true if the input is number.

 

Example

Check for positive integer

For example, if the flowchart expects a positive integer as input, we can combine the above function with further checks.

For integer the floor(n) == n holds true. And to be positive integer n should be > 0.

 

Input validation Examples

The above flowchart example halts after displaying an error message. We can even display an error message and prompt the user to Try again if the user enters invalid input.

Such examples to prompt user to Try again after invalid input can be found here:

Recursive way to validate user input in the flowchart:

https://www.testingdocs.com/questions/raptor-flowchart-to-find-the-number-of-digits-in-a-number/

https://www.testingdocs.com/questions/how-to-find-square-root-of-a-number-in-raptor-flowchart/

Similar functions

Similar functions that are useful to validate input are:

Is_Character(param)

This function returns True when the argument is a Character.

Is_String(param)
This function returns True when the argument is a String.

Is_Array(param)
This function returns True when the argument is an Array.

—-

RAPTOR tutorial page: https://www.testingdocs.com/raptor-a-flowchart-tool/

Flowchart examples: https://www.testingdocs.com/raptor-flowchart-examples/

 

Exit mobile version