Skip to content

Commit 2e59943

Browse files
committed
Parse boolean to enum
1 parent 902e86c commit 2e59943

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/schemas.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import * as z from 'zod'
22

33
export const SEVERITIES = ['critical', 'high', 'moderate', 'low'] as const
44
export const SCOPES = ['unknown', 'runtime', 'development'] as const
5+
export const COMMENT_SUMMARY_OPTIONS = [
6+
'always',
7+
'never',
8+
'on-failure'
9+
] as const
510

611
export const SeveritySchema = z.enum(SEVERITIES).default('low')
712

@@ -47,7 +52,17 @@ export const ConfigurationOptionsSchema = z
4752
config_file: z.string().optional(),
4853
base_ref: z.string().optional(),
4954
head_ref: z.string().optional(),
50-
comment_summary_in_pr: z.enum(['always', 'never', 'on-failure']).default('never'),
55+
comment_summary_in_pr: z
56+
.union([z.boolean(), z.enum(COMMENT_SUMMARY_OPTIONS)])
57+
.default('never')
58+
})
59+
.transform(config => {
60+
if (config.comment_summary_in_pr === true) {
61+
config.comment_summary_in_pr = 'always'
62+
} else if (config.comment_summary_in_pr === false) {
63+
config.comment_summary_in_pr = 'never'
64+
}
65+
return config
5166
})
5267
.superRefine((config, context) => {
5368
if (config.allow_licenses && config.deny_licenses) {

0 commit comments

Comments
 (0)