Skip to content

Commit 16acbd3

Browse files
committed
Modify config validation to allow only width i.e FPS
1 parent 197c876 commit 16acbd3

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/lib/ctx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default (options: Record<string, string>): Context => {
2929
process.exit();
3030
}
3131

32-
for (let viewport of config.web.viewports) viewports.push({ width: viewport[0], height: viewport[1]});
32+
for (let viewport of config.web.viewports) viewports.push({ width: viewport[0], height: viewport[1] || 0});
3333
return {
3434
env: env,
3535
log: logger,

src/lib/schemaValidation.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,26 @@ const ConfigSchema = {
3434
type: "array",
3535
items: {
3636
type: "array",
37-
items: [
38-
{ type: "number", minimum: 320, maximum: 7680 },
39-
{ type: "number", minimum: 320, maximum: 7680 }
40-
],
41-
additionalItems: false,
42-
minItems: 2,
43-
maxItems: 2
37+
oneOf: [
38+
{
39+
items: [{ type: "number", minimum: 320, maximum: 7680 }],
40+
minItems: 1,
41+
maxItems: 1
42+
},
43+
{
44+
items: [
45+
{ type: "number", minimum: 320, maximum: 7680 },
46+
{ type: "number", minimum: 320, maximum: 7680 }
47+
],
48+
minItems: 2,
49+
maxItems: 2
50+
}
51+
],
52+
errorMessage: "Invalid config; width/height must be >= 320 and <= 7680"
4453
},
4554
uniqueItems: true,
4655
maxItems: 5,
47-
errorMessage: "Invalid config; width/height must be >= 320 and <= 7680; max viewports allowed - 5"
56+
errorMessage: "Invalid config; max unique viewports allowed - 5"
4857
},
4958
waitForPageRender: {
5059
type: "number",

0 commit comments

Comments
 (0)