Ejemplo n.º 1
0
 class Meta(BaseCompanySerializer.Meta):
     fields = (
         *BaseCompanySerializer.Meta.fields,
         'address',
         'registered_address',
     )
     dnb_read_only_fields = (
         *BaseCompanySerializer.Meta.dnb_read_only_fields,
         'address',
         'registered_address',
     )
     validators = (
         *BaseCompanySerializer.Meta.validators,
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('uk_region', bool),
                 when=EqualsRule(
                     'address_country',
                     Country.united_kingdom.value.id,
                 ),
             ),
             ValidationRule(
                 'uk_establishment_not_in_uk',
                 EqualsRule('address_country',
                            Country.united_kingdom.value.id),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
     )
Ejemplo n.º 2
0
 class Meta(CompanySerializer.Meta):
     read_only_fields = []
     dnb_read_only_fields = []
     validators = (
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('company_number', bool),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_characters',
                 OperatorRule('company_number',
                              has_no_invalid_company_number_characters),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_prefix',
                 OperatorRule('company_number',
                              has_uk_establishment_number_prefix),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
         RulesBasedValidator(
             ValidationRule(
                 'uk_establishment_not_in_uk',
                 EqualsRule('address_country',
                            Country.united_kingdom.value.id),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ), ),
     )
Ejemplo n.º 3
0
 class Meta:
     model = Interaction
     extra_kwargs = {
         # Date is a datetime in the model, but only the date component is used
         # (at present). Setting the formats as below effectively makes the field
         # behave like a date field without changing the schema and breaking the
         # v1 API.
         'date': {
             'format': '%Y-%m-%d',
             'input_formats': ['%Y-%m-%d']
         },
         'grant_amount_offered': {
             'min_value': 0
         },
         'net_company_receipt': {
             'min_value': 0
         },
         'status': {
             'default': Interaction.STATUSES.complete,
             'allow_null': False
         },
         'location': {
             'default': ''
         },
         'theme': {
             'allow_blank': False,
             'default': None,
         },
     }
     fields = (
         'id',
         'company',
         'contacts',
         'created_on',
         'created_by',
         'event',
         'is_event',
         'status',
         'kind',
         'modified_by',
         'modified_on',
         'date',
         'dit_adviser',
         'dit_participants',
         'dit_team',
         'communication_channel',
         'grant_amount_offered',
         'investment_project',
         'net_company_receipt',
         'service',
         'service_delivery_status',
         'subject',
         'theme',
         'notes',
         'archived_documents_url_path',
         'policy_areas',
         'policy_feedback_notes',
         'policy_issue_types',
         'was_policy_feedback_provided',
         'location',
         'archived',
         'archived_by',
         'archived_on',
         'archived_reason',
     )
     read_only_fields = (
         'archived_documents_url_path',
         'archived',
         'archived_by',
         'archived_on',
         'archived_reason',
     )
     validators = [
         HasAssociatedInvestmentProjectValidator(),
         ContactsBelongToCompanyValidator(),
         StatusChangeValidator(),
         RulesBasedValidator(
             # If dit_adviser and dit_team are *omitted* (note that they already have
             # allow_null=False) we assume that dit_participants is being used, and return an
             # error if it is empty.
             # TODO: Remove once dit_adviser and dit_team have been removed.
             ValidationRule(
                 'required',
                 OperatorRule('dit_participants', bool),
                 when=AllIsBlankRule('dit_adviser', 'dit_team'),
             ),
             # If dit_adviser has been provided, double-check that dit_team is also set.
             # TODO: Remove once dit_adviser and dit_team have been removed.
             ValidationRule(
                 'required',
                 OperatorRule('dit_adviser', bool),
                 when=AndRule(
                     OperatorRule('dit_team', bool),
                     OperatorRule('dit_participants', not_),
                 ),
             ),
             # If dit_team has been provided, double-check that dit_adviser is also set.
             # TODO: Remove once dit_adviser and dit_team have been removed.
             ValidationRule(
                 'required',
                 OperatorRule('dit_team', bool),
                 when=AndRule(
                     OperatorRule('dit_adviser', bool),
                     OperatorRule('dit_participants', not_),
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('communication_channel', bool),
                 when=AndRule(
                     EqualsRule('kind', Interaction.KINDS.interaction),
                     EqualsRule('status', Interaction.STATUSES.complete),
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('service', bool),
                 when=EqualsRule('status', Interaction.STATUSES.complete),
             ),
             ValidationRule(
                 'invalid_for_non_interaction',
                 OperatorRule('investment_project', not_),
                 when=EqualsRule('kind',
                                 Interaction.KINDS.service_delivery),
             ),
             ValidationRule(
                 'invalid_for_service_delivery',
                 OperatorRule('communication_channel', not_),
                 when=EqualsRule('kind',
                                 Interaction.KINDS.service_delivery),
             ),
             ValidationRule(
                 'invalid_for_non_service_delivery',
                 OperatorRule('is_event', is_blank),
                 OperatorRule('event', is_blank),
                 OperatorRule('service_delivery_status', is_blank),
                 OperatorRule('grant_amount_offered', is_blank),
                 OperatorRule('net_company_receipt', is_blank),
                 when=EqualsRule('kind', Interaction.KINDS.interaction),
             ),
             ValidationRule(
                 'invalid_when_no_policy_feedback',
                 OperatorRule('policy_issue_types', not_),
                 OperatorRule('policy_areas', not_),
                 OperatorRule('policy_feedback_notes', not_),
                 when=OperatorRule('was_policy_feedback_provided', not_),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('policy_areas', bool),
                 OperatorRule('policy_issue_types', bool),
                 OperatorRule('policy_feedback_notes', is_not_blank),
                 when=OperatorRule('was_policy_feedback_provided', bool),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('is_event', is_not_blank),
                 when=EqualsRule('kind',
                                 Interaction.KINDS.service_delivery),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('event', bool),
                 when=OperatorRule('is_event', bool),
             ),
             ValidationRule(
                 'too_many_contacts_for_event_service_delivery',
                 OperatorRule('contacts', lambda value: len(value) <= 1),
                 when=OperatorRule('is_event', bool),
             ),
             ValidationRule(
                 'invalid_for_non_event',
                 OperatorRule('event', not_),
                 when=OperatorRule('is_event', not_),
             ),
         ),
     ]
Ejemplo n.º 4
0
 class Meta:
     model = Company
     fields = (
         'id',
         'reference_code',
         'name',
         'trading_name',
         'uk_based',
         'company_number',
         'vat_number',
         'registered_address_1',
         'registered_address_2',
         'registered_address_town',
         'registered_address_county',
         'registered_address_postcode',
         'registered_address_country',
         'created_on',
         'modified_on',
         'archived',
         'archived_documents_url_path',
         'archived_on',
         'archived_reason',
         'archived_by',
         'description',
         'website',
         'trading_address_1',
         'trading_address_2',
         'trading_address_town',
         'trading_address_county',
         'trading_address_postcode',
         'trading_address_country',
         'business_type',
         'classification',
         'companies_house_data',
         'contacts',
         'employee_range',
         'export_to_countries',
         'future_interest_countries',
         'headquarter_type',
         'one_list_account_owner',
         'global_headquarters',
         'sector',
         'turnover_range',
         'uk_region',
         'export_experience_category',
     )
     read_only_fields = (
         'archived',
         'archived_documents_url_path',
         'archived_on',
         'archived_reason',
         'reference_code',
     )
     validators = [
         RequiredUnlessAlreadyBlankValidator('sector', 'business_type'),
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('uk_region', bool),
                 when=EqualsRule(
                     'registered_address_country',
                     Country.united_kingdom.value.id,
                 ),
             ),
             ValidationRule(
                 'uk_establishment_not_in_uk',
                 EqualsRule('registered_address_country',
                            Country.united_kingdom.value.id),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('company_number', bool),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_characters',
                 OperatorRule('company_number',
                              has_no_invalid_company_number_characters),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_prefix',
                 OperatorRule('company_number',
                              has_uk_establishment_number_prefix),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
         AddressValidator(
             lazy=True,
             fields_mapping=Company.TRADING_ADDRESS_VALIDATION_MAPPING),
     ]
     permissions = {
         f'company.{CompanyPermission.view_company_document}':
         'archived_documents_url_path',
     }
Ejemplo n.º 5
0
 class Meta:
     model = Interaction
     extra_kwargs = {
         # Date is a datetime in the model, but only the date component is used
         # (at present). Setting the formats as below effectively makes the field
         # behave like a date field without changing the schema and breaking the
         # v1 API.
         'date': {'format': '%Y-%m-%d', 'input_formats': ['%Y-%m-%d']},
         'grant_amount_offered': {'min_value': 0},
         'net_company_receipt': {'min_value': 0},
         'status': {'default': Interaction.Status.COMPLETE},
         'theme': {
             'allow_blank': False,
             'default': None,
         },
     }
     fields = (
         'id',
         'company',
         'contacts',
         'created_on',
         'created_by',
         'event',
         'is_event',
         'status',
         'kind',
         'modified_by',
         'modified_on',
         'date',
         'dit_participants',
         'communication_channel',
         'grant_amount_offered',
         'investment_project',
         'net_company_receipt',
         'service',
         'service_answers',
         'service_delivery_status',
         'subject',
         'theme',
         'notes',
         'archived_documents_url_path',
         'policy_areas',
         'policy_feedback_notes',
         'policy_issue_types',
         'was_policy_feedback_provided',
         'were_countries_discussed',
         'export_countries',
         'archived',
         'archived_by',
         'archived_on',
         'archived_reason',
         'company_referral',
     )
     read_only_fields = (
         'archived_documents_url_path',
         'archived',
         'archived_by',
         'archived_on',
         'archived_reason',
     )
     # Note: These validators are also used by the admin site import interactions tool
     # (see the admin_csv_import sub-package)
     validators = [
         HasAssociatedInvestmentProjectValidator(),
         ContactsBelongToCompanyValidator(),
         StatusChangeValidator(),
         ServiceAnswersValidator(),
         DuplicateExportCountryValidator(),
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('communication_channel', bool),
                 when=AndRule(
                     EqualsRule('kind', Interaction.Kind.INTERACTION),
                     EqualsRule('status', Interaction.Status.COMPLETE),
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('service', bool),
                 when=EqualsRule('status', Interaction.Status.COMPLETE),
             ),
             ValidationRule(
                 'invalid_for_investment',
                 EqualsRule('kind', Interaction.Kind.INTERACTION),
                 when=EqualsRule('theme', Interaction.Theme.INVESTMENT),
             ),
             ValidationRule(
                 'invalid_for_non_interaction',
                 OperatorRule('investment_project', not_),
                 when=EqualsRule('kind', Interaction.Kind.SERVICE_DELIVERY),
             ),
             ValidationRule(
                 'invalid_for_service_delivery',
                 OperatorRule('communication_channel', not_),
                 when=EqualsRule('kind', Interaction.Kind.SERVICE_DELIVERY),
             ),
             ValidationRule(
                 'invalid_for_non_service_delivery',
                 OperatorRule('is_event', is_blank),
                 OperatorRule('event', is_blank),
                 OperatorRule('service_delivery_status', is_blank),
                 when=EqualsRule('kind', Interaction.Kind.INTERACTION),
             ),
             ValidationRule(
                 'invalid_when_no_policy_feedback',
                 OperatorRule('policy_issue_types', not_),
                 OperatorRule('policy_areas', not_),
                 OperatorRule('policy_feedback_notes', not_),
                 when=OperatorRule('was_policy_feedback_provided', not_),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('policy_areas', bool),
                 OperatorRule('policy_issue_types', bool),
                 OperatorRule('policy_feedback_notes', is_not_blank),
                 when=OperatorRule('was_policy_feedback_provided', bool),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('is_event', is_not_blank),
                 when=EqualsRule('kind', Interaction.Kind.SERVICE_DELIVERY),
             ),
             ValidationRule(
                 'too_many_contacts_for_event_service_delivery',
                 OperatorRule('contacts', lambda value: len(value) <= 1),
                 when=OperatorRule('is_event', bool),
             ),
             ValidationRule(
                 'invalid_for_investment',
                 OperatorRule('were_countries_discussed', not_),
                 OperatorRule('export_countries', not_),
                 when=EqualsRule('theme', Interaction.Theme.INVESTMENT),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('were_countries_discussed', is_not_blank),
                 when=AndRule(
                     IsObjectBeingCreated(),
                     InRule(
                         'theme',
                         [Interaction.Theme.EXPORT, Interaction.Theme.OTHER],
                     ),
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('export_countries', is_not_blank),
                 when=AndRule(
                     OperatorRule('were_countries_discussed', bool),
                     InRule(
                         'theme',
                         [Interaction.Theme.EXPORT, Interaction.Theme.OTHER],
                     ),
                 ),
             ),
             ValidationRule(
                 'invalid_when_no_countries_discussed',
                 OperatorRule('export_countries', is_blank),
                 when=AndRule(
                     IsObjectBeingCreated(),
                     OperatorRule('were_countries_discussed', not_),
                     InRule(
                         'theme',
                         [Interaction.Theme.EXPORT, Interaction.Theme.OTHER],
                     ),
                 ),
             ),
             # These two rules are only checked for service deliveries as there's a separate
             # check that event is blank for interactions above which takes precedence (to
             # avoid duplicate or contradictory error messages)
             ValidationRule(
                 'required',
                 OperatorRule('event', bool),
                 when=AndRule(
                     OperatorRule('is_event', bool),
                     EqualsRule('kind', Interaction.Kind.SERVICE_DELIVERY),
                 ),
             ),
             ValidationRule(
                 'invalid_for_non_event',
                 OperatorRule('event', not_),
                 when=AndRule(
                     OperatorRule('is_event', not_),
                     EqualsRule('kind', Interaction.Kind.SERVICE_DELIVERY),
                 ),
             ),
         ),
     ]
def test_equals_rule(data, field, test_value, res):
    """Tests ValidationCondition for various cases."""
    combiner = Mock(spec_set=DataCombiner, __getitem__=lambda self, field_: data[field_])
    condition = EqualsRule(field, test_value)
    assert condition(combiner) == res
Ejemplo n.º 7
0
 class Meta:
     model = Company
     fields = (
         'id',
         'reference_code',
         'name',
         'trading_names',
         'uk_based',
         'company_number',
         'vat_number',
         'duns_number',
         'created_on',
         'modified_on',
         'archived',
         'archived_documents_url_path',
         'archived_on',
         'archived_reason',
         'archived_by',
         'description',
         'transferred_by',
         'transferred_on',
         'transferred_to',
         'transfer_reason',
         'website',
         'business_type',
         'one_list_group_tier',
         'contacts',
         'employee_range',
         'number_of_employees',
         'is_number_of_employees_estimated',
         'export_to_countries',
         'future_interest_countries',
         'headquarter_type',
         'one_list_group_global_account_manager',
         'global_headquarters',
         'sector',
         'turnover_range',
         'turnover',
         'is_turnover_estimated',
         'uk_region',
         'export_experience_category',
         'address',
         'registered_address',
         'pending_dnb_investigation',
         'export_potential',
         'great_profile_status',
         'is_global_ultimate',
         'global_ultimate_duns_number',
         'dnb_modified_on',
         'export_countries',
     )
     read_only_fields = (
         'archived',
         'archived_documents_url_path',
         'archived_on',
         'archived_reason',
         'reference_code',
         'transfer_reason',
         'duns_number',
         'turnover',
         'is_turnover_estimated',
         'number_of_employees',
         'is_number_of_employees_estimated',
         'pending_dnb_investigation',
         'export_potential',
         'great_profile_status',
         'is_global_ultimate',
         'global_ultimate_duns_number',
         'dnb_modified_on',
         'export_countries',
     )
     dnb_read_only_fields = (
         'name',
         'trading_names',
         'company_number',
         'vat_number',
         'business_type',
         'employee_range',
         'turnover_range',
         'address',
         'registered_address',
     )
     validators = (
         RequiredUnlessAlreadyBlankValidator('sector', 'business_type'),
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('company_number', bool),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_characters',
                 OperatorRule('company_number',
                              has_no_invalid_company_number_characters),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
             ValidationRule(
                 'invalid_uk_establishment_number_prefix',
                 OperatorRule('company_number',
                              has_uk_establishment_number_prefix),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('uk_region', bool),
                 when=EqualsRule(
                     'address_country',
                     Country.united_kingdom.value.id,
                 ),
             ),
             ValidationRule(
                 'uk_establishment_not_in_uk',
                 EqualsRule('address_country',
                            Country.united_kingdom.value.id),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
     )
     permissions = {
         f'company.{CompanyPermission.view_company_document}':
         'archived_documents_url_path',
         'company.view_companyexportcountry': 'export_countries',
     }
Ejemplo n.º 8
0
 class Meta(BaseCompanySerializer.Meta):
     extra_kwargs = {
         'registered_address_2': {
             'default': ''
         },
         'registered_address_county': {
             'default': ''
         },
         'registered_address_postcode': {
             'default': ''
         },
         'trading_address_1': {
             'default': ''
         },
         'trading_address_2': {
             'default': ''
         },
         'trading_address_town': {
             'default': ''
         },
         'trading_address_county': {
             'default': ''
         },
         'trading_address_postcode': {
             'default': ''
         },
     }
     fields = (
         *BaseCompanySerializer.Meta.fields,
         'companies_house_data',
         'registered_address_1',
         'registered_address_2',
         'registered_address_town',
         'registered_address_county',
         'registered_address_postcode',
         'registered_address_country',
         'trading_address_1',
         'trading_address_2',
         'trading_address_town',
         'trading_address_county',
         'trading_address_postcode',
         'trading_address_country',
     )
     dnb_read_only_fields = (
         *BaseCompanySerializer.Meta.dnb_read_only_fields,
         'registered_address_1',
         'registered_address_2',
         'registered_address_town',
         'registered_address_county',
         'registered_address_postcode',
         'registered_address_country',
         'trading_address_1',
         'trading_address_2',
         'trading_address_town',
         'trading_address_county',
         'trading_address_postcode',
         'trading_address_country',
     )
     validators = (
         *BaseCompanySerializer.Meta.validators,
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('uk_region', bool),
                 when=EqualsRule(
                     'registered_address_country',
                     Country.united_kingdom.value.id,
                 ),
             ),
             ValidationRule(
                 'uk_establishment_not_in_uk',
                 EqualsRule('registered_address_country',
                            Country.united_kingdom.value.id),
                 when=EqualsRule(
                     'business_type',
                     BusinessTypeConstant.uk_establishment.value.id,
                 ),
             ),
         ),
         AddressValidator(
             lazy=True,
             fields_mapping=Company.TRADING_ADDRESS_VALIDATION_MAPPING),
     )
Ejemplo n.º 9
0
 class Meta:
     model = Interaction
     extra_kwargs = {
         # Date is a datetime in the model, but only the date component is used
         # (at present). Setting the formats as below effectively makes the field
         # behave like a date field without changing the schema and breaking the
         # v1 API.
         'date': {
             'format': '%Y-%m-%d',
             'input_formats': ['%Y-%m-%d']
         },
         'grant_amount_offered': {
             'min_value': 0
         },
         'net_company_receipt': {
             'min_value': 0
         },
     }
     fields = (
         'id',
         'company',
         'contact',
         'created_on',
         'created_by',
         'event',
         'is_event',
         'kind',
         'modified_by',
         'modified_on',
         'date',
         'dit_adviser',
         'dit_team',
         'communication_channel',
         'grant_amount_offered',
         'investment_project',
         'net_company_receipt',
         'service',
         'service_delivery_status',
         'subject',
         'notes',
         'archived_documents_url_path',
         'policy_areas',
         'policy_issue_type',
     )
     read_only_fields = ('archived_documents_url_path', )
     validators = [
         KindPermissionValidator(),
         HasAssociatedInvestmentProjectValidator(),
         RulesBasedValidator(
             ValidationRule(
                 'required',
                 OperatorRule('communication_channel', bool),
                 when=InRule(
                     'kind',
                     [
                         Interaction.KINDS.interaction,
                         Interaction.KINDS.policy_feedback,
                     ],
                 ),
             ),
             ValidationRule(
                 'invalid_for_non_interaction',
                 OperatorRule('investment_project', not_),
                 when=InRule(
                     'kind',
                     [
                         Interaction.KINDS.service_delivery,
                         Interaction.KINDS.policy_feedback,
                     ],
                 ),
             ),
             ValidationRule(
                 'invalid_for_service_delivery',
                 OperatorRule('communication_channel', not_),
                 when=EqualsRule('kind',
                                 Interaction.KINDS.service_delivery),
             ),
             ValidationRule(
                 'invalid_for_non_service_delivery',
                 OperatorRule('is_event', is_blank),
                 OperatorRule('event', is_blank),
                 OperatorRule('service_delivery_status', is_blank),
                 OperatorRule('grant_amount_offered', is_blank),
                 OperatorRule('net_company_receipt', is_blank),
                 when=InRule(
                     'kind',
                     [
                         Interaction.KINDS.interaction,
                         Interaction.KINDS.policy_feedback,
                     ],
                 ),
             ),
             ValidationRule(
                 'invalid_for_non_policy_feedback',
                 OperatorRule('policy_areas', not_),
                 OperatorRule('policy_issue_type', is_blank),
                 when=InRule(
                     'kind',
                     [
                         Interaction.KINDS.interaction,
                         Interaction.KINDS.service_delivery,
                     ],
                 ),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('is_event', is_not_blank),
                 when=EqualsRule('kind',
                                 Interaction.KINDS.service_delivery),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('policy_areas', bool),
                 OperatorRule('policy_issue_type', is_not_blank),
                 when=EqualsRule('kind', Interaction.KINDS.policy_feedback),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('event', bool),
                 when=OperatorRule('is_event', bool),
             ),
             ValidationRule(
                 'invalid_for_non_event',
                 OperatorRule('event', not_),
                 when=OperatorRule('is_event', not_),
             ),
             ValidationRule(
                 'required',
                 OperatorRule('notes', is_not_blank),
                 when=OperatorRule('is_event', not_),
             ),
         ),
     ]