Skip to content

Commit ced5dc1

Browse files
authored
impr(config): validation on layoutFluid and polyglot (@fehmer) (monkeytypegame#6844)
1 parent cd99d5a commit ced5dc1

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

frontend/__tests__/root/config.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,9 @@ describe("Config", () => {
10891089
expect(Config.setQuoteLength([-4 as any, 5 as any])).toBe(false);
10901090
});
10911091
it("setCustomLayoutfluid", () => {
1092-
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(true);
1092+
expect(Config.setCustomLayoutfluid(["qwerty", "qwertz"])).toBe(true);
10931093

1094+
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(false);
10941095
expect(Config.setCustomLayoutfluid([])).toBe(false);
10951096
expect(Config.setCustomLayoutfluid("qwerty#qwertz" as any)).toBe(false);
10961097
expect(Config.setCustomLayoutfluid("invalid" as any)).toBe(false);

frontend/src/ts/pages/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ async function fillSettingsPage(): Promise<void> {
607607
customLayoutFluidSelect = new SlimSelect({
608608
select:
609609
".pageSettings .section[data-config-name='customLayoutfluid'] select",
610-
settings: { keepOrder: true, minSelected: 1 },
610+
settings: { keepOrder: true, minSelected: 2 },
611611
events: {
612612
afterChange: (newVal): void => {
613613
const customLayoutfluid = newVal.map(
@@ -625,7 +625,7 @@ async function fillSettingsPage(): Promise<void> {
625625

626626
customPolyglotSelect = new SlimSelect({
627627
select: ".pageSettings .section[data-config-name='customPolyglot'] select",
628-
settings: { minSelected: 1 },
628+
settings: { minSelected: 2 },
629629
data: getLanguageDropdownData((language) =>
630630
Config.customPolyglot.includes(language)
631631
),

packages/schemas/src/configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ export type CustomBackgroundFilter = z.infer<
211211

212212
export const CustomLayoutFluidSchema = z
213213
.array(Layouts.LayoutNameSchema)
214-
.min(1)
214+
.min(2)
215215
.max(15);
216216
export type CustomLayoutFluid = z.infer<typeof CustomLayoutFluidSchema>;
217217

218-
export const CustomPolyglotSchema = z.array(LanguageSchema).min(1);
218+
export const CustomPolyglotSchema = z.array(LanguageSchema).min(2);
219219
export type CustomPolyglot = z.infer<typeof CustomPolyglotSchema>;
220220

221221
export const MonkeyPowerLevelSchema = z.enum(["off", "1", "2", "3", "4"]);

0 commit comments

Comments
 (0)