It needs to be valid
If you are Australian or South African, the rules are different.
Entry requirements for Americans: US citizens require a passport valid for period of intended stay and a return ticket or proof of onward travel. No visa is required for a stay of up to three months.
Entry requirements for UK nationals: UK citizens must hold a valid passport. No visa is required for a maximum stay of 90 days.
Entry requirements for Canadians: Canadians require a passport valid for period of intended stay and a return ticket or proof of onward travel. No visa is required for a stay of up to three months.
Entry requirements for Australians: Australian citizens require a passport valid for at least three months beyond expiry date of visa. No visa is required for stays of up to 90 days.
Entry requirements for South Africans: South Africans should apply in advance for a visa to enter Spain. Passports should be valid for at least three months beyond expiry date of visa.