def validate(self, attrs):
        '''
        1. Disallow starts-with, which complicates validation, and
           is unnecessary for file uploading
        2. Require that required_conditions are present
        3. Make sure conditions are in required_conditions or
           optional_conditions
        4. Invoke super, which checks for duplicate keys and
           invokes the validate_condition_<element_name> methods
        '''
        conditions = attrs.get('conditions', [])
        errors = {}
        missing_conditions = set(self.required_conditions) - set([item.element_name for item in conditions])
        for element_name in missing_conditions:
            message = _('Required condition is missing')
            errors['conditions.' + element_name] = [message]
        for item in conditions:
            field_name = 'conditions.' + item.element_name
            if item.operator and item.operator != 'eq':
                message = _("starts-with and operators other than 'eq' are not allowed")
                errors[field_name] = errors.get(field_name, []) + [message]
            elif item.element_name not in self.required_conditions + self.optional_conditions:
                message = _('Invalid element name')
                errors[field_name] = errors.get(field_name, []) + [message]
        try:
            super(DefaultPolicySerializer, self).validate(attrs)
        except __HOLE__ as err:
            # Merge with our errors
            for field_name, error_messages in err.message_dict.items():
                errors[field_name] = errors.get(field_name, []) + list(error_messages)
        if len(errors):
            raise ValidationError(errors)
        else:
            return attrs
dataset/ETHPy150Open bodylabs/drf-to-s3/drf_to_s3/serializers.py/DefaultPolicySerializer.validate