I am newbie to C++ and am trying to teach myself to program. Could someone please explain in very simple language what data validation means and how should I check for it (in relation to input data) before any processing occurs.

:-| Merlin208

13 Years
Discussion Span
Last Post by Chainsaw

Let's say you want an interactive program to input two numbers, add them together, and display the result. The user types some text, right? Was that text actually representing a valid number? Or do you just blindly add two values that may or may not be there. Data validation, in the context I understand from your question, is merely making sure that the user actually entered two numbers before you try to add them.


When you explain your program, you make assumptions about what the data is. 'data validation' is when you test for those assumptions in your code.

"My program inputs an age, and I assume the age is between 10 and 100. Then I compute ...."

so, when you input the number that is supposed to be the age, you would verify that it is between 10 and 100 and if not, complain. THAT is data validation.

Dave said that too, I guess. :-)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.