def validate_event_type(sender, event, created):
    """Verify that the Event's code is a valid one."""
    if event.code not in sender.event_codes():
        raise ValueError("The Event.code '{}' is not a valid Event "
                         "code.".format(event.code))
Verify that the Event's code is a valid one.