How do I know that the data received from serial is valid?

Maybe example 2 and up in Serial Input Basics - updated will give an idea.

If you use delay() in your program, you can easily get buffer overruns as mentioned above.

Post your code and we might be able to advise further. What is the sending side; any protocol involved?