It was the democratic will of the people of Catalonia, which in this instance, is what matters.
The only reason the referendum wasn't "valid" is because the court declared it so. The expressed will of the people who voted would be the same either way.
Actually, no, it was not a legitimate referendum and a voter turnout of 43% clearly shows that a sizeable chunk of the Catalan people boycotted the vote precisely because it wasn't legitimate. You see an election result of 92% pro-secession with 57% of eligible voters not even participating and you think that's democratic? It's not.
A link to an official Catalan government site that was shared here earlier shows how they are indeed trying to rewrite history and create an invented national narrative, in a way that should make any historian shudder. I've come across Catalan nationalists on other history forums discussing Antiquity related subjects, and they were significantly annoying. They were doing a lot of the bad kind of revisionism. You know, the obviously political type of historical revisionism. There were different groups of them and then I realized it's all part of a concerted effort to create, or better said, invent an new national identity at the expense of their own integrity and respectability. It's creepy... One of my Belgian friends once referred to Puigdemont as a crypto-fascist, which made me chuckle. He and many around him indeed seem to be wolves in sheep's clothing.
I don't understand the mentality behind pointing fingers at Spanish nationalists while not pointing fingers at the obviously very dirty games that Catalan nationalists have been playing as well. They have literally forced the hand of Madrid, in a well coordinated manner, to create a victim narrative. Madrid clearly handled the situation without much tact, but few countries remain cool when their territorial integrity is at stake. Catalonia is full of Castilian speakers as well. There's no way to separate the two in a clean manner without creating even bigger rifts than there already are.