'Validate the event registration form
@param form: the FORM'

def validate(self, form):

    T = current.T
    formvars = form.vars
    pe_label = formvars.get('label').strip()
    person = self.get_person(pe_label)
    if (person is None):
        form.errors['label'] = T('No    person    found    with    this    ID    number')
        permitted = False
    else:
        person_id = person.id
        formvars.person_id = person_id
        flag_info = dvr_get_flag_instructions(person_id, action=self.ACTION)
        permitted = flag_info['permitted']
    formvars.permitted = permitted
    type_id = None
    try:
        request_vars = form.request_vars
    except AttributeError:
        event_code = None
    else:
        event_code = request_vars.get('event')
    if event_code:
        event_type = self.get_event_type(event_code)
        if (not event_type):
            form.errors['event'] = current.response.error = T('Invalid    event    code')
        else:
            type_id = event_type.id
    formvars.type_id = type_id
    if (person and type_id):
        blocked = self.get_blocked_events(person.id, type_id=type_id)
        if (type_id in blocked):
            (msg, earliest) = blocked[type_id]
            form.errors['event'] = current.response.error = msg
