'Check whether an email is valid. Allows blank emails.
Additionally checks if a newsletter is requested, and will be strict
on blank emails if so.'

@csrf_exempt
@json_validate(email=ValidEmail('email'), newsletter_subscribe=VBoolean('newsletter_subscribe', default=False), sponsor=VBoolean('sponsor', default=False))
def POST_check_email(self, responder, email, newsletter_subscribe, sponsor):

    if (newsletter_subscribe and (not email)):
        c.errors.add(errors.NEWSLETTER_NO_EMAIL, field='email')
        responder.has_errors('email', errors.NEWSLETTER_NO_EMAIL)
        return
    if (sponsor and (not email)):
        c.errors.add(errors.SPONSOR_NO_EMAIL, field='email')
        responder.has_errors('email', errors.SPONSOR_NO_EMAIL)
        return
    if (not responder.has_errors('email', errors.BAD_EMAIL)):
        return {}
