Skip to content

Commit

Permalink
Parse boolean to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmurphy committed Aug 9, 2023
1 parent 902e86c commit 2e59943
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import * as z from 'zod'

export const SEVERITIES = ['critical', 'high', 'moderate', 'low'] as const
export const SCOPES = ['unknown', 'runtime', 'development'] as const
export const COMMENT_SUMMARY_OPTIONS = [
'always',
'never',
'on-failure'
] as const

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

Expand Down Expand Up @@ -47,7 +52,17 @@ export const ConfigurationOptionsSchema = z
config_file: z.string().optional(),
base_ref: z.string().optional(),
head_ref: z.string().optional(),
comment_summary_in_pr: z.enum(['always', 'never', 'on-failure']).default('never'),
comment_summary_in_pr: z
.union([z.boolean(), z.enum(COMMENT_SUMMARY_OPTIONS)])
.default('never')
})
.transform(config => {
if (config.comment_summary_in_pr === true) {
config.comment_summary_in_pr = 'always'
} else if (config.comment_summary_in_pr === false) {
config.comment_summary_in_pr = 'never'
}
return config
})
.superRefine((config, context) => {
if (config.allow_licenses && config.deny_licenses) {
Expand Down

0 comments on commit 2e59943

Please sign in to comment.