first commit
This commit is contained in:
27
libs/encounter-library/src/lib/validate-encounters.ts
Normal file
27
libs/encounter-library/src/lib/validate-encounters.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { z } from 'zod';
|
||||
|
||||
const encounterRecord = z.object({
|
||||
id: z.string().min(1),
|
||||
tier: z.string(),
|
||||
baseSuccessChance: z.number().min(0).max(1),
|
||||
difficultyTags: z.array(z.string()),
|
||||
perkTags: z.array(z.string()),
|
||||
flavor: z.array(z.string()).min(1)
|
||||
});
|
||||
|
||||
const encounterDocument = z.object({
|
||||
schemaVersion: z.number().int().min(1),
|
||||
records: z.array(encounterRecord)
|
||||
});
|
||||
|
||||
function main(): void {
|
||||
const file = resolve(process.cwd(), 'libs/encounter-library/src/lib/encounters.json');
|
||||
const raw = readFileSync(file, 'utf-8');
|
||||
const parsed = JSON.parse(raw) as unknown;
|
||||
encounterDocument.parse(parsed);
|
||||
process.stdout.write('Encounter library validation passed.\n');
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user