Error messaging is hard.
You have to consider every contingency and reason for why an error might pop-up and then encompass those scenarios in just a few characters.
And, just as a general rule, you don't want to use negative or condescending language.
Nobody likes to read the word "invalid", especially when it applies to them.
So, try to be upbeat.
Quick story: my Dad did a 'thing' when we were young, and he knew that we were lying.
He'd catch us in an innocent lie and go " Hmm, are you sure you brushed your teeth?" And then we'd crack, run away and brush our teeth!
It worked every time. And, curiously, we never got mad at my Dad for catching us in a lie.
It was a smart way to deliver bad news.
Anyway, that's one general philosophy to keep in mind when it comes to writing error copy: never shame the user, never give them a reason to be angry at your language, always be helpful, even when you're not.