Skip to content

Commit 781c606

Browse files
committed
fix(relationship.schema): replace .transform with .check
- transform was returning a JSON object rather than self (the zod schema) - this breaks downstream extensions of the relationship schema - replacing with check maintains functionality but ensures the schema is returned
1 parent d9c0cbf commit 781c606

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/schemas/sro/relationship.schema.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,18 @@ export const relationshipSchema = attackBaseRelationshipObjectSchema
303303
.check((ctx) => {
304304
createRelationshipValidationRefinement()(ctx);
305305
})
306-
.transform((data) => {
306+
.check((ctx) => {
307307
// Check for deprecated pattern
308-
const [sourceType] = data.source_ref.split('--') as [StixType];
308+
const [sourceType] = ctx.value.source_ref.split('--') as [StixType];
309309
if (
310310
sourceType === 'x-mitre-data-component' &&
311-
data.relationship_type === 'detects' &&
312-
data.target_ref.startsWith('attack-pattern--')
311+
ctx.value.relationship_type === 'detects' &&
312+
ctx.value.target_ref.startsWith('attack-pattern--')
313313
) {
314314
console.warn(
315315
'DEPRECATION WARNING: x-mitre-data-component -> detects -> attack-pattern relationships are deprecated',
316316
);
317317
}
318-
return data;
319318
});
320319

321320
export type Relationship = z.infer<typeof relationshipSchema>;

0 commit comments

Comments
 (0)