Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,13 @@ describe('PagerDuty Schema', () => {
})
).toThrow();
});

it('validates customDetails as a JSON string and coerces to object', () => {
const customDetailsObject = { key: 'value' };
const result = ParamsSchema.parse({
customDetails: JSON.stringify(customDetailsObject),
});
expect(result.customDetails).toEqual(customDetailsObject);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import { i18n } from '@kbn/i18n';
import { z } from '@kbn/zod';
import moment from 'moment';
import { convertTimestamp } from '../../common/utils';
import { convertTimestamp, Coerced } from '../../common/utils';

import {
EVENT_ACTIONS_WITH_REQUIRED_DEDUPKEY,
EVENT_ACTION_ACKNOWLEDGE,
Expand All @@ -36,7 +37,7 @@ const EventActionSchema = z.enum([

const PayloadSeveritySchema = z.enum(['critical', 'error', 'warning', 'info']);
const LinksSchema = z.array(z.object({ href: z.string(), text: z.string() }).strict());
const customDetailsSchema = z.record(z.string(), z.any());
const customDetailsSchema = Coerced(z.record(z.string(), z.any()));

export const ParamsSchema = z
.object({
Expand Down
Loading