def add_collection_errors(<EOL>self,<EOL>property_name,<EOL>direct_errors=None,<EOL>collection_errors=None<EOL>):
if direct_errors is None and collection_errors is None:<EOL><INDENT>return self<EOL><DEDENT>if direct_errors is not None:<EOL><INDENT>if type(direct_errors) is not list:<EOL><INDENT>direct_errors = [direct_errors]<EOL><DEDENT>if property_name not in self.errors:<EOL><INDENT>self.errors[property_name] = dict()<EOL><DEDENT>if '<STR_LIT>' not in self.errors[property_name]:<EOL><INDENT>self.errors[property_name]['<STR_LIT>'] = []<EOL><DEDENT>for error in direct_errors:<EOL><INDENT>if not isinstance(error, Error):<EOL><INDENT>err = '<STR_LIT>'<EOL>raise x.InvalidErrorType(err.format(Error))<EOL><DEDENT>self.errors[property_name]['<STR_LIT>'].append(error)<EOL><DEDENT><DEDENT>if collection_errors:<EOL><INDENT>enum = enumerate(collection_errors)<EOL>errors_dict = {i: e for i, e in enum if not bool(e)}<EOL>if not errors_dict:<EOL><INDENT>return self<EOL><DEDENT>if property_name not in self.errors:<EOL><INDENT>self.errors[property_name] = dict()<EOL><DEDENT>if '<STR_LIT>' not in self.errors[property_name]:<EOL><INDENT>self.errors[property_name]['<STR_LIT>'] = errors_dict<EOL><DEDENT>else:<EOL><INDENT>local = self.errors[property_name]['<STR_LIT>']<EOL>remote = errors_dict<EOL>for index, result in remote.items():<EOL><INDENT>if index not in local:<EOL><INDENT>self.errors[property_name]['<STR_LIT>'][index] = result<EOL><DEDENT>else:<EOL><INDENT>merged = self.merge_errors(<EOL>local[index].errors,<EOL>remote[index].errors<EOL>)<EOL>self.errors[property_name]['<STR_LIT>'][index] = merged<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return self<EOL>
Add collection errors
Accepts a list errors coming from validators attached directly,
or a list of schema results for each item in the collection.

:param property_name: str, property name
:param direct_errors: list, errors from validators attached directly
:param collection_errors: list of results for collection members
:return: shiftschema.result.Result