Skip to content

Commit 29dafad

Browse files
committed
validation for threshold values
1 parent db3c867 commit 29dafad

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/lib/ctx.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export default (options: Record<string, string>): Context => {
3737
delete config.web.resolutions;
3838
}
3939

40+
if(config.approvalThreshold && config.rejectionThreshold) {
41+
if(config.rejectionThreshold <= config.approvalThreshold) {
42+
throw new Error('Invalid config; rejectionThreshold must be greater than approvalThreshold');
43+
}
44+
}
45+
4046
let validateConfigFn = options.scheduled ? validateConfigForScheduled : validateConfig;
4147

4248
// validate config

src/lib/server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
3838
try {
3939
let { snapshot, testType } = request.body;
4040
if (!validateSnapshot(snapshot)) throw new Error(validateSnapshot.errors[0].message);
41+
42+
if(snapshot?.options?.approvalThreshold && snapshot?.options?.rejectionThreshold) {
43+
if(snapshot?.options?.rejectionThreshold <= snapshot?.options?.approvalThreshold) {
44+
throw new Error('Invalid snapshot; rejectionThreshold must be greater than approvalThreshold');
45+
}
46+
}
4147

4248
// Fetch sessionId from snapshot options if present
4349
const sessionId = snapshot?.options?.sessionId;

0 commit comments

Comments
 (0)