Validate the manditory keys.

def _validate_mandatory_keys(mandatory, validated, data, to_validate):
    """Validate the manditory keys."""
    errors = []
    for key, sub_schema in mandatory.items():
        if key not in data:
            errors.append('missing key: %r' % (key,))
            continue
        try:
            validated[key] = sub_schema(data[key])
        except NotValid as ex:
            errors.extend(['%r: %s' % (key, arg) for arg in ex.args])
        to_validate.remove(key)
    return errors