def to_internal_value(self, value):
        value = super(PatchItem, self).to_internal_value(value)
        if set(value.keys()) != set(['op', 'path', 'value']):
            raise ValidationError("Missing some of required parts: 'path', 'op', 'value'")
        if value['path'][0] != '/':
            raise ValidationError({'path': "Invalid path"})
        value['path'] = tuple(value['path'].split('/')[1:])

        if self.parent.serializer:
            try:
                field = get_field_for_path(self.parent.serializer, value['path'])
            except __HOLE__ as e:
                raise ValidationError({'path': "Missing elem: '%s'" % e.args[0]})

            # import pdb; pdb.set_trace()

            if value['op'] in ('set', 'inc', 'dec'):
                if field is not None:
                    value['value'] = field.to_internal_value(value['value'])
            elif value['op'] in ('push', 'add_to_set'):
                field = getattr(field, 'child')
                if field is not None:
                    value['value'] = field.to_internal_value(value['value'])
            elif value['op'] in ('unset', 'pull', 'pull_all', 'min', 'max'):
                if value['value'] is not None:
                    raise ValidationError({'value': "Value for '%s' expected to be null" % value['op']})
            elif value['op'] in ('pop',):
                try:
                    value['value'] = int(value['value'])
                except:
                    raise ValidationError({'value': "Integer expected for '%s'" % value['op']})

        return value
dataset/ETHPy150Open umutbozkurt/django-rest-framework-mongoengine/rest_framework_mongoengine/contrib/patching.py/PatchItem.to_internal_value