Article 155 [source]

Spanish Criminal Code
English translation

In cases of assault, if the victim has given valid, free, spontaneous, and express consent, the penalty will be reduced by one or two degrees.

Consent given by a minor or a person with a disability requiring special protection will not be valid.