-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisConfig.ts
47 lines (42 loc) · 1 KB
/
isConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { IConfig } from "./interfaces/IConfig.ts";
export const isConfig = (config: unknown): config is IConfig => {
if (!isRecord(config)) {
return false;
}
if (
Object.keys(config).filter((key) =>
[
"firstSeedNumber",
"seedCount",
"romPath",
"outputPath",
"randomizerSettingsPath",
"randomizerJarPath",
].includes(key)
).length === 0
) {
return false;
}
if (typeof config.firstSeedNumber !== "number") {
return false;
}
if (typeof config.seedCount !== "number") {
return false;
}
if (typeof config.romPath !== "string") {
return false;
}
if (typeof config.outputPath !== "string") {
return false;
}
if (typeof config.randomizerSettingsPath !== "string") {
return false;
}
if (typeof config.randomizerJarPath !== "string") {
return false;
}
return true;
};
const isRecord = (value: unknown): value is Record<string, unknown> => {
return typeof value === "object" && value !== null;
};