def __init__(self, docs):
    '\n        Initialize from database documents.\n\n        :param docs: Database document.\n        :type docs: list[dict]\n        '
    if (not docs):
        _invalid('At least one MIME type rule is required')
    self._rules = list()
    max_index = (len(docs) - 1)
    for (index, mime_type_rule) in enumerate(docs):
        if (index < max_index):
            location = 'MIME type rule #{}'.format((index + 1))
            if (mime_type_rule.get('pattern', '').strip() == ''):
                _invalid('Pattern is required', location)
            if ('save' not in mime_type_rule):
                _invalid('Save selector is required', location)
            if ('match' not in mime_type_rule):
                _invalid('Match selector is required', location)
            try:
                pattern_re = re.compile(mime_type_rule['pattern'])
            except:
                _invalid('Invalid regular expression', location)
            self._rules.append((pattern_re, mime_type_rule['match'], mime_type_rule['save']))
        else:
            location = 'last MIME type rule'
            if ('save' not in mime_type_rule):
                _invalid('Save selector is required', location)
            if ('pattern' in mime_type_rule):
                _invalid('Pattern is not allowed', location)
            if ('match' in mime_type_rule):
                _invalid('Match selector is not allowed', location)
            self._rules.append((None, None, mime_type_rule['save']))
Initialize from database documents.

:param docs: Database document.
:type docs: list[dict]
def __init__(self, docs):
    '\n        Initialize from database documents.\n\n        :param docs: Database document.\n        :type docs: list[dict]\n        '
    if (not docs):
        _invalid('At least one MIME type rule is required')
    self._rules = list()
    max_index = (len(docs) - 1)
    for (index, mime_type_rule) in enumerate(docs):
        if (index < max_index):
            location = 'MIME type rule #{}'.format((index + 1))
            if (mime_type_rule.get('pattern', ).strip() == ):
                _invalid('Pattern is required', location)
            if ('save' not in mime_type_rule):
                _invalid('Save selector is required', location)
            if ('match' not in mime_type_rule):
                _invalid('Match selector is required', location)
            try:
                pattern_re = re.compile(mime_type_rule['pattern'])
            except:
                _invalid('Invalid regular expression', location)
            self._rules.append((pattern_re, mime_type_rule['match'], mime_type_rule['save']))
        else:
            location = 'last MIME type rule'
            if ('save' not in mime_type_rule):
                _invalid('Save selector is required', location)
            if ('pattern' in mime_type_rule):
                _invalid('Pattern is not allowed', location)
            if ('match' in mime_type_rule):
                _invalid('Match selector is not allowed', location)
            self._rules.append((None, None, mime_type_rule['save']))