def is_valid(self):
        """
        Enforce validation for ``value`` based on ``type_controlled``.
        """
        val = super(AttributeForm, self).is_valid()

        if all(x in self.cleaned_data for x in ['value', 'type_controlled']):
            value = self.cleaned_data['value']
            attr_type = self.cleaned_data['type_controlled']
            if (value and not attr_type) or (attr_type and not value):
                self.add_error('value', 'Missing data')
            try:
                value_model = attr_type.value_content_type.model_class()
            except AttributeError as E:
                self.add_error('type_controlled', 'No type selected')
                value_model = None

            if value_model:
                try:
                    value_model.is_valid(value)
                except __HOLE__ as E:
                    self.add_error('value', E)
        return super(AttributeForm, self).is_valid()
dataset/ETHPy150Open upconsulting/IsisCB/isiscb/zotero/admin.py/AttributeForm.is_valid