Also, depending of how you send the whole thing, you may also check for a "end" character. If the string is right but the next character/byte is false, you discard the result.

All the time, you want to implement a structured "serial data message" on both side.