def validate_key(self, key):
try:<EOL><INDENT>confirmation = models.EmailConfirmation.objects.select_related(<EOL>"<STR_LIT>"<EOL>).get(key=key)<EOL><DEDENT>except models.EmailConfirmation.DoesNotExist:<EOL><INDENT>raise serializers.ValidationError(<EOL>_("<STR_LIT>")<EOL>)<EOL><DEDENT>if confirmation.is_expired:<EOL><INDENT>raise serializers.ValidationError(<EOL>_("<STR_LIT>")<EOL>)<EOL><DEDENT>self._confirmation = confirmation<EOL>return key<EOL>
Validate the provided confirmation key.

Returns:
    str:
        The validated confirmation key.

Raises:
    serializers.ValidationError:
        If there is no email confirmation with the given key or
        the confirmation has expired.