Skip to content

Commit 4f5fd09

Browse files
committed
refactor(models): extract scoreTargetSchema
1 parent 44e4934 commit 4f5fd09

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/models/src/lib/category-config.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
} from './implementation/checks.js';
66
import {
77
metaSchema,
8-
nonnegativeNumberSchema,
98
scorableSchema,
9+
scoreTargetSchema,
1010
slugSchema,
1111
weightedRefSchema,
1212
} from './implementation/schemas.js';
@@ -44,12 +44,7 @@ export const categoryConfigSchema = scorableSchema(
4444
description: 'Meta info for category',
4545
}).shape,
4646
)
47-
.extend({
48-
scoreTarget: nonnegativeNumberSchema
49-
.max(1)
50-
.describe('Pass/fail score threshold (0-1)')
51-
.optional(),
52-
});
47+
.extend({ scoreTarget: scoreTargetSchema });
5348

5449
export type CategoryConfig = z.infer<typeof categoryConfigSchema>;
5550

packages/models/src/lib/implementation/schemas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ export function packageVersionSchema<
172172
}>;
173173
}
174174

175+
/** Schema for a binary score threshold */
176+
export const scoreTargetSchema = nonnegativeNumberSchema
177+
.max(1)
178+
.describe('Pass/fail score threshold (0-1)')
179+
.optional();
180+
175181
/** Schema for a weight */
176182
export const weightSchema = nonnegativeNumberSchema.describe(
177183
'Coefficient for the given score (use weight 0 if only for display)',

0 commit comments

Comments
 (0)