# Path: shared_schema_tenants/exceptions.py
# class TenantFieldTypeConfigurationError(Exception):
# 
#     def __init__(self, message="The field is not configured correctly", errors=[]):
#         super(TenantFieldTypeConfigurationError, self).__init__(message)
# 
# Path: shared_schema_tenants/helpers/tenants.py
# def get_current_tenant():
#     from shared_schema_tenants.middleware import TenantMiddleware
#     return TenantMiddleware.get_current_tenant()


import sys
from django.core.exceptions import ValidationError
from django.utils.text import ugettext_lazy as _
from shared_schema_tenants.exceptions import TenantFieldTypeConfigurationError
from shared_schema_tenants.helpers.tenants import get_current_tenant

    def validate_field(self, context, key, value, original_value=None):
        tenant_fields = self.get_tenant_fields()

        try:
            field = tenant_fields[key]
        except KeyError:
            raise ValidationError(_('%(field)s is not a valid field') % {'field': key})

        try:
            field_type = field['type']
        except KeyError:
            raise TenantFieldTypeConfigurationError((
                'You must define a valid type for tenant setting '
                'field "%(field)s" in "TENANT_SETTINGS_FIELDS"') % {'field': key})

        if field_type not in self.TYPES_TO_INTERNAL_MAP.keys():
            raise TenantFieldTypeConfigurationError((
                '"%(wrong_type)s" of field %(field)s is not a valid type. '
                'Use one of these: %(valid_types)s') % {
                    'wrong_type': field_type,
                    'field': key,
                    'valid_types': ', '.join(
                        [('"%s"' % t) for t in self.TYPES_TO_INTERNAL_MAP.keys()])
            })

        if tenant_fields[key].get('required', True):
            if value == None or value == '':  # noqa
                raise ValidationError({
                    key: [

# Path: shared_schema_tenants/exceptions.py
# class TenantFieldTypeConfigurationError(Exception):
# 
#     def __init__(self, message="The field is not configured correctly", errors=[]):
#         super(TenantFieldTypeConfigurationError, self).__init__(message)
# 
# Path: shared_schema_tenants/helpers/tenants.py
# def get_current_tenant():
#     from shared_schema_tenants.middleware import TenantMiddleware
#     return TenantMiddleware.get_current_tenant()


# Path: shared_schema_tenants/helpers/tenant_json_field.py
import sys
from django.core.exceptions import ValidationError
from django.utils.text import ugettext_lazy as _
from shared_schema_tenants.exceptions import TenantFieldTypeConfigurationError
from shared_schema_tenants.helpers.tenants import get_current_tenant


    def validate_field(self, context, key, value, original_value=None):
        tenant_fields = self.get_tenant_fields()

        try:
            field = tenant_fields[key]
        except KeyError:
            raise ValidationError(_('%(field)s is not a valid field') % {'field': key})

        try:
            field_type = field['type']
        except KeyError:
            raise TenantFieldTypeConfigurationError((
                'You must define a valid type for tenant setting '
                'field "%(field)s" in "TENANT_SETTINGS_FIELDS"') % {'field': key})

        if field_type not in self.TYPES_TO_INTERNAL_MAP.keys():
            raise TenantFieldTypeConfigurationError((
                '"%(wrong_type)s" of field %(field)s is not a valid type. '
                'Use one of these: %(valid_types)s') % {
                    'wrong_type': field_type,
                    'field': key,
                    'valid_types': ', '.join(
                        [('"%s"' % t) for t in self.TYPES_TO_INTERNAL_MAP.keys()])
            })

        if tenant_fields[key].get('required', True):
            if value == None or value == '':  # noqa
                raise ValidationError({
                    key: [

                        _('This field is required')