Skip to content

Commit

Permalink
Merge branch 'cases-custom-fields-feature-branch' of github.com:elast…
Browse files Browse the repository at this point in the history
…ic/kibana into cases-custom-fields-feature-branch
  • Loading branch information
cnasikas committed Oct 2, 2023
2 parents 0447625 + d1c8bb8 commit 4f164aa
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
29 changes: 0 additions & 29 deletions x-pack/plugins/cases/server/client/cases/validators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,34 +403,5 @@ describe('validators', () => {
})
).toThrowErrorMatchingInlineSnapshot(`"Missing required custom fields: first_key"`);
});

it('throws if request sends a custom field that is not part of the configuration', () => {
const requestCustomFields: CaseCustomFields = [
{
key: 'first_key',
type: CustomFieldTypes.TEXT as const,
value: ['foo'],
},
{
key: 'second_key',
type: CustomFieldTypes.TOGGLE,
value: true,
},
];
const customFieldsConfiguration: CustomFieldsConfiguration = [
{
key: 'first_key',
type: CustomFieldTypes.TEXT,
label: 'foo',
required: true,
},
];
expect(() =>
validateRequiredCustomFields({
requestCustomFields,
customFieldsConfiguration,
})
).toThrowErrorMatchingInlineSnapshot(`"Unknown custom fields: second_key"`);
});
});
});
10 changes: 0 additions & 10 deletions x-pack/plugins/cases/server/client/cases/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ export const validateRequiredCustomFields = ({
}
}

const notRegisteredCustomFields = differenceWith(
requestCustomFields ?? [],
customFieldsConfiguration,
(requestedVal, requiredVal) => requestedVal.key === requiredVal.key
).map((e) => e.key);

if (notRegisteredCustomFields.length) {
throw Boom.badRequest(`Unknown custom fields: ${notRegisteredCustomFields}`);
}

const requiredCustomFields = customFieldsConfiguration.filter(
(customField) => customField.required
);
Expand Down

0 comments on commit 4f164aa

Please sign in to comment.